简体   繁体   中英

Boost Graph - using both directed and undirected edges

What would be the best strategy to build a boost graph that holds both directed and undirected edges?

I want to model a social network, where nodes represent people, and edges represent relationships. Some relationships are undirected (BrotherOf), while other are directed (FatherOf).

I need something like in_edges, out_edges and undirected_edges iterators.

Edit:

Since I need to deal with very large graphs, I want a method which is efficient both in memory consumption and in algorithms execution speed.

You could simply represent it as a directed graph.

An undirected edge can then be represented by replacing it with a directed edge in both directions.

There's a fairly simple way: a graph for the brother relationship, another for the father relationship. Or one for all undirected relationships, and one for directed relationships, which may include the undirected ones in both directions so that the standard graph algorithms work as expected.

Represent it as a directed graph.

And if edges have too many properties, you can just store a pointer to your data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM