I'm working on implementing an algorithm to determine the graphical structure of a dataset. The dataset could have undirected or directed edges between variables. I could create my own graph object in Python, but I was curious if Networkx has this capability. From what I've seen, Networkx only has a Graph object (only undirected edges) and a DiGraph object (for directed edges only). Is there a way to include directed edges in a undirected graph in Networkx and/or vice versa?
All the edges in a graph must be either DIRECTED or UNDIRECTED. The two types of edges cannot be mixed together. A graph that uses only DIRECTED EDGES is called a DIRECTED GRAPH. Likewise, a graph that uses only UNDIRECTED EDGES is called an UNDIRECTED GRAPH.
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.
networkx
has no mixed graph handling. There were discussions about it, but the implementation had an impact on the whole library, so it was suspended. As I know, graph-tool
and igraph
has no this functionality too. If you are not satisfied by bidirected edges as undirected, I am afraid you should not use Python libraries, because it is impossible to have both directed and undirected edges in the most popular Python graph libraries: networkx
, graph-tool
and igraph
.
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