Question on Creating Custom Verticies And Edges

Sep 17, 2008 at 10:14 PM
Edited Sep 17, 2008 at 10:15 PM
Hello again,

I was looking for some examples using the new version of QuickGraph 2.0 to understand how to use quickgraph to model the results of an electrical network trace into a graph.

I have access to the tabular trace results in a database table with the following column layout:
  • TraceOrder - The order in which this device was found.
  • SourceFeatureId - The Parent's Feature Id that this device is connected with.
  • SourceNode - The Parent's NodeId that this device is physically connected to (could be either Node1 or Node2).
  • Cost - The cost of getting to this node.  Incremented by 1 for each path.
  • Node1 - This node's connection point 1.
  • Node2 - This node's connection point 2.
  • FeatureId - This node's Feature Id (unique identifier).
  • FeatureType - This node's Feature type (breaker, switch, etc)

Here is some sample data:
 

TRACEORDER SOURCEFID SOURCENODE COST NODE1 NODE2 FID FNO
1 0 0 0 0 35818053 32352823 300
2 32352823 35818053 1 35818053 35818054 32494596 236
3 32494596 35818054 2 35818054 35817201 32494597 236
4 32494597 35817201 3 35817201 35818050 32494598 236
5 32494598 35818050 4 35818050 35818051 32494599 313
6 32494599 35818051 5 35818051 35817490 32494600 306
7 32494600 35817490 6 35817490 35817202 32494602 306
7 32494600 35817490 6 35817490 35817491 32494601 314


Can some one help point me in the right direction?  I found this code here, and I wanted to create my own vertext and edge type by inheriting from Vertex or Edge but those classes do not exist in QuickGraph 2.0.  http://blog.dotnetwiki.org/FunWithGraphs3CreatingTheGraphOfADatabaseStructure.aspx

I'd really appreciate some of your expertise in this matter.

Coordinator
Sep 18, 2008 at 12:53 AM
The data structures in QuickGraph 2.0 are generic, so the Vertex type does not exist anymore. Let's assume you have a type called 'Node', then you simply have to declare this to get a adjacency graph:

var g = new AdjacencyGraph<Node, Edge<Node>>();

Note that you can specialize Edge<Node> to add more data to it.