简体   繁体   中英

Networkx : Make a graph more readable

Good afternoon.

I'm on a shortest path finder with A* project, and for that I took some osm data with osmnx. When I want to plot my graph, I don't manage to print something good, even with changing the k parameter of spring_layout. Also, I would like to print my nodes labels, and my edges labels without printing the tuple {"weight", label}. I honestly didn't found how to make the whole thing clearer...

Do you have any idea?

if __name__ == '__main__':
    Data = open('edgelist_bruxelles.csv', "r")
    Graphtype = nx.MultiDiGraph()

    G = nx.parse_edgelist(Data, delimiter=',', create_using=Graphtype,
                          nodetype=int, data=(('weight', float),))
    
    pos = nx.spring_layout(G, 10)
    
    nx.draw_networkx_nodes(G, pos, node_size=50)
    nx.draw_networkx_edge_labels(G, pos, font_size=5)
    nx.draw_networkx_edges(G, pos, edge_color='r', arrows=True)
    mp.show()

What I have now

1

Here are some things you could consider:

  1. Add a title, perhaps some labels explaining what the nodes and vertices represent.
  2. Determine what you want to show about the data. Currently, it is difficult to draw conclusions beyond 'many relationships'. If there is a particular path that you'd like to highlight, an approach could be to only display a smaller subset of the relationships or nodes.
  3. You could also use color coding or something of the like to make things stand out more. For example, create a colormap for the different vertex values and see if anything stands out.
  4. Removes nodes or order them deliberately to create less of a spiderweb.

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