1
votes

I have an existing graph, built from my own vertex and edge classes, as follows:

struct Graph;

struct OutPort {};

struct InPort { 
  OutPort* connectedOutput; 
};

struct Node { 
  Graph* graph;
  std::list<InPort> inputs;
  std::list<OutPort> outputs;
};

struct Graph {
  std::list<Node> nodes;
}

That is, the graph is composed of nodes, which have 0..* input and output ports. An input port be connected to to 0..1 output ports of any node (including its own).

I would like to apply the BGL algorithms to this graph, but cannot figure out how to do it while using either keeping my existing data structures above, or provide a suitable mapping between them and the BGL data structures.

I would be grateful for an introductory example.

1

1 Answers

0
votes

Making the example is a little bit involved. However, you need to model a graph concept of your choosing.

http://www.boost.org/doc/libs/1_63_0/libs/graph/doc/graph_concepts.html

enter image description here

I find it hard to see from your model how edges are represented (ports could well be disconnected, or maybe OutPort refers back to a Node etc.). I sense you might want to model AdjacencyGraph. The required operations are listed on the linked page.