If the same edge is added twice to the networkx
edge data structure, will it then have two edges between the nodes or still just one? For example, would a spring layout show the nodes converge more with edges [(a,b),(a,b),(a,b),(a,b)]
than [(a,b),(a,b)]
? If I want to weight the edge, how would I go about it?
A multidigraph is a directed graph which is permitted to have multiple arcs, i.e., arcs with the same source and target nodes. A multidigraph G is an ordered pair G := (V, A) with. V a set of vertices or nodes, A a multiset of ordered pairs of vertices called directed edges, arcs or arrows.
A MultiGraph holds undirected edges. Self loops are allowed.
A DiGraph stores nodes and edges with optional data, or attributes. DiGraphs hold directed edges. Self loops are allowed but multiple (parallel) edges are not. Nodes can be arbitrary (hashable) Python objects with optional key/value attributes.
Add an edge between u and v. The nodes u and v will be automatically added if they are not already in the graph. Edge attributes can be specified with keywords or by directly accessing the edge's attribute dictionary.
You can test it pretty quickly, but it only adds them once. Edges and nodes are represented as a dictionaries inside the graph structure, and they are only added if they don't actually exist.
For already existing edges, adding them again has no effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With