简体   繁体   中英

What's the difference between a SparseMultigraph<V, E> and a SparseGraph<V, E>?

I'm using JUNG2 library and they have 2 similar Graphs which are:

  • SparseMultigraph
  • SparseGraph

Can someone tell me the differences between them?

Thanks.

I think SparseGraph<V, E> does not support parallel edges.

while SparseMultigraph<V, E> allows parallel edges.

Multigraph: https://en.wikipedia.org/wiki/Multigraph

The name of the class(es) almost tell it.

  • SparseMultigraph is a multigraph, which means that there might be multiple (>= 1) or zero edges between two vertices. The SparseMultigraph class implements the Multigraph interface.

  • SparseGraph is a graph, which means that there is exactly 0 or exactly 1 edge between any two vertices. The SparseGraph class doesn't not implement the Multigraph interface, but only the Graph interface.

  • Both classes extend the AbstractGraph class.

More info:

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