1

I am using QuickGraph .NET library which is a clone for boost (C++) graph library but I have some few questions as I'm totally new to this library 1- How would I represent undirected graph in QucikGraph? I found that you can do it easily in boost using: adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph; 2- How would I assign values to vertices I am interested to attach integer values to vertices but I couldn't figure out how to do this:

AdjacencyGraph graph = new AdjacencyGraph(new VertexAndEdgeProvider(), false);//I'm not sure about the proper value of this boolean 
IVertex u = graph.AddVertex();// here I'm adding vertex to 'graph' but with no value 
IVertex v = graph.AddVertex();// here also I'm doing the same thing but without assigning any value to vertex v
graph.AddEdge(u, v);
Ibrahim Amer
  • 1,147
  • 4
  • 19
  • 46

1 Answers1

0

Here's how to go about it: Suppose your vertices vertex1 and vertex2 are of type T, you should use the following piece of code (NB: Namespace will be using QuickGraph;):

AdjacencyGraph<T, Edge<T>> newGraphInstance = new AdjacencyGraph<int, Edge<int>>();
newGraphInstance.AddVerticesAndEdge(new Edge<T>(vertex1, vertex2));

This will add both the vertices and the corresponding edge.

Soma Mbadiwe
  • 1,594
  • 16
  • 15