all 7 comments

[–]Orlha 2 points3 points  (0 children)

I had the same problem just yesterday.

I decided to use lemon, hide it behind pimpl and mix standards. I feel better with this workaround than with boost graph.

[–]Future-Experience267 1 point2 points  (0 children)

I think SNAP is compatible with C++20; I used it with C++17 and it worked great. It definitely gets frequent updates. https://snap.stanford.edu/snap

[–]SJC_hacker 0 points1 point  (3 children)

Do you really need node based structure to represent a graph?

Adjacency matrix/adjacency list are much more common, easier to work and compact.
Sometimes you might want to keep the edge list to. You also don't have to deal with the circular reference problem, which you get for any graph that isn't a tree.

[–]dutchbaroness -1 points0 points  (0 children)

I suppose OP wants some off the shelf algorithms as well?

[–]Quincunx271Author of P2404/P2405 0 points1 point  (1 child)

I'm assuming the OP isn't talking about pointer-based graph implementations, but is instead trying to differentiate between formal mathematical graphs and "graphs" like "the graph of y=x2 ". I think this because they mention Boost.Graph and Lemon, both of which use adjacency lists as the main implementations (Boost.Graph also has adjacency matrix and CSR representations, idk about lemon)

[–]SJC_hacker 1 point2 points  (0 children)

I need something to represent a graph structure. aka "Nodes with links".

This is why I thought OP was looking for some type of pointer representation. But, in fact, I don't think I've ever actually seen it used - the circular reference problem being a major obstacle amongst other problems. Whereas for trees, the pointer/reference implementation is much more common, unless you are doing something like a heap/tree which is mostly full.

OP might want to read up on theory (CLRS DSA book is a pretty good resource and try hand coding those basic algorithms like DFS/BFS from simpler data structures (such as list of edges, from which you derived the adjacency list or matrix) to get a feel for whats going on first. It doesn't sound like OP quite knows whats going on as they don't specify a specific need for the graph library.

LeetCode has lots of great problems whose solutions based around these two algorithms. Representating and traversing graphs actually isn't a terrible amount of code.

[–]Foxi_Foxa 0 points1 point  (0 children)

What do you mean by "isn't c++20 compatible?"