Skip to content Skip to sidebar Skip to footer

How To Stop Networkx From Changing The Order Of Head And Tail Nodes(u,v) To (v,u) In An Edge?

I've got a simple graph created using networkx. import networkx as nx import matplotlib.pyplot as plt from pprint import pprint G = nx.Graph() head_nodes = range(0, 9) tail_nodes

Solution 1:

A Graph is an undirected graph, where (1, 13) and (13, 1) mean the same thing, the edges have no 'arrows'.

What you want is a DiGraph, meaning a directed graph. See https://networkx.github.io/documentation/stable/reference/classes/index.html

An OrderedGraph is something else - it just means that when you iterate over nodes and edges, they come out in a particular order (similar to lists vs sets).

Post a Comment for "How To Stop Networkx From Changing The Order Of Head And Tail Nodes(u,v) To (v,u) In An Edge?"