Been a few years since I put NetworkX through its paces, but the several times I have tried it, found remarkably weak support for graph layout and display. NetworkX analytic routines may be strong, but attractively displaying graph-structured problems remarkably more interactive and attractive via d3.js, GraphViz, etc. At least for my problems, communicating graph structures, and having nodes and edges that represent different kinds of things…these are basic requirements, not optional frills.
> Been a few years since I put NetworkX through its paces, but the several times I have tried it, found remarkably weak support for graph layout and display.
Well, yeah, it is pretty open that it is the wrong tool for that job. Here's what the NetworkX documentation [0] says about its visualization support:
NetworkX provides basic functionality for visualizing graphs, but its main goal is to enable graph analysis rather than perform graph visualization. In the future, graph visualization functionality may be removed from NetworkX or only available as an add-on package.
Proper graph visualization is hard, and we highly recommend that people visualize their graphs with tools dedicated to that task. Notable examples of dedicated and fully-featured graph visualization tools are Cytoscape, Gephi, Graphviz and, for LaTeX typesetting, PGF/TikZ. To use these and other such tools, you should export your NetworkX graph into a format that can be read by those tools. For example, Cytoscape can read the GraphML format, and so, networkx.write_graphml(G, path) might be an appropriate choice.
Laying out a graph so it's "friendly to humans" is a seriously hard problem. I've built complex DAG workflow engines using networkx and its layout tools and they worked just fine. But, yeah, I guess it depends on what you need?
Export the graph to GML or to GraphML or to GraphViz DOT or to some other Graph format, and feed it to a dedicated utility. BTW I recommend 3D graph visualization over 2D when possible, that is when you're exploring interactively as opposed to printing figures. The Graphia tool is the only FOSS tool for this purpose that I know of:
You may like my Netgraph library [1], which is a Python library that aims to complement networkx, igraph, and graph-tool with publication-quality visualisations.
Netgraph implements numerous node layout algorithms and several edge routing routines. Uniquely among Python alternatives, it handles networks with multiple components gracefully (which otherwise break most node layout routines), and it post-processes the output of the node layout and edge routing algorithms with several heuristics to increase the interpretability of the visualisation (reduction of overlaps between nodes, edges, and labels; edge crossing minimisation and edge unbundling where applicable). The highly customisable plots are created using Matplotlib, and the resulting Matplotlib objects are exposed in an easily queryable format such that they can be further manipulated and/or animated using standard Matplotlib syntax. Finally, Netgraph also supports interactive changes: with the InteractiveGraph class, nodes and edges can be positioned using the mouse, and the EditableGraph class additionally supports insertion and deletion of nodes and edges as well as their (re-)labelling through standard text-entry.
If I want to visualize a graph, particularly large ones I just dump it out to gexf[0] format and load it into gephi[1]. It kicks back some legacy formatting errors but it doesn't really impact the graph. Gephi also supports temporal based graph analysis which is nice.
I definitely agree. There’s no reason in my opinion not to have an extension library that does good visualization via a force-directed graph or similar. The existing visualization methods are pretty barebones.
I found the documentation for networkx much better than the one from igraph[1] (at least the Python version). However, for community detection algorithms graph-tool[2] is better (it also uses a different class of models than the standard in literature)
NetworkX let me whip up a useful shortest path routing proof of concept from telco data in a few hours. I was impressed with myself, but all glory goes to NetworkX !
Interesting you should say that, as I am trying to start a project where I need to make an electric grid graph, but I am not sure where to find the node/edge data for substations and transmission lines that include their specs and capacities. Is that stuff open source somewhere, like with the ISOs, or do you need to build it from scratch?
That data is privately held by utilities, and the high voltage transmission infrastructure is highly confidential (CEII/NERC CIP). If you just need sample data, I'd recommend checking out the test data provided with power flow simulators like OpenDSS for distribution systems [1] or MATPOWER for generation + transmission [2]. The IEEE test systems are what are used in research, they have the component specs you're looking for, and are provided with those tools.
I have tried to talk to engineers about contingency analyses for what would happen if a unit went down, and they tend to have very wishy washy answers. Or giant tediously compiled reports that can model exactly one change.
Good question. Are you talking about generation, transmission or distribution?
From my experience as an electrical engineer working for a distribution network:
* The traditional approach to network planning: take your edge cases (e.g. winter peak demand), and apply your engineering knowledge and intuition to manually study the most onerous outage conditions.
* This will vary on where you are in the world, but networks tend to have a good amount of slack built in.
* As networks become more complex, and the cost of computing has fallen, it's more feasible to automate contingency analysis (think about the number of different outage combinations for an N-2 scenario).
FWIW, the internal tools that I work on makes use of networkx to determine contingency cases.
A single unit would correspond to a N-1 case when doing a transmission system study. There are ways of automating steady state analysis for this case to do a full sweep across the nearby system (either looking at k hops away, all parts in a zone (where a zone has a specific meaning in this context), or using a utility provided set of assets for the analysis). This pretty much consists of running a load flow for each individual case and compiling the results while making sure they are valid (convergence, device behavior, etc).
This is only the steady state analysis, but there's also dynamics done when looking at specific generators also to look at a generator's response to fluctuations in voltage and frequency to ensure stability within certain operating conditions (weakening of the grid, rapid change in voltage or freq).
If they were wishy washy they were probably limited to doing distribution where you are assuming a single strong source (swing bus) at the substation and it's not your responsibility to think too much about adjusting the system behavior based off of changes in transmission (usually)
[1] "What are the best libraries to work with graphs?" https://www.reddit.com/r/Python/comments/185xexg/what_are_th...
Well, yeah, it is pretty open that it is the wrong tool for that job. Here's what the NetworkX documentation [0] says about its visualization support:
NetworkX provides basic functionality for visualizing graphs, but its main goal is to enable graph analysis rather than perform graph visualization. In the future, graph visualization functionality may be removed from NetworkX or only available as an add-on package.
Proper graph visualization is hard, and we highly recommend that people visualize their graphs with tools dedicated to that task. Notable examples of dedicated and fully-featured graph visualization tools are Cytoscape, Gephi, Graphviz and, for LaTeX typesetting, PGF/TikZ. To use these and other such tools, you should export your NetworkX graph into a format that can be read by those tools. For example, Cytoscape can read the GraphML format, and so, networkx.write_graphml(G, path) might be an appropriate choice.
[0] https://networkx.org/documentation/latest/reference/drawing....
Export to .dot -> open in your favourite viewer.
https://graphia.app
https://github.com/graphia-app/graphia
Netgraph implements numerous node layout algorithms and several edge routing routines. Uniquely among Python alternatives, it handles networks with multiple components gracefully (which otherwise break most node layout routines), and it post-processes the output of the node layout and edge routing algorithms with several heuristics to increase the interpretability of the visualisation (reduction of overlaps between nodes, edges, and labels; edge crossing minimisation and edge unbundling where applicable). The highly customisable plots are created using Matplotlib, and the resulting Matplotlib objects are exposed in an easily queryable format such that they can be further manipulated and/or animated using standard Matplotlib syntax. Finally, Netgraph also supports interactive changes: with the InteractiveGraph class, nodes and edges can be positioned using the mouse, and the EditableGraph class additionally supports insertion and deletion of nodes and edges as well as their (re-)labelling through standard text-entry.
[1] https://github.com/paulbrodersen/netgraph
[0] https://networkx.org/documentation/stable/reference/readwrit... [1] https://gephi.org/
https://cosmograph.app/
Deleted Comment
[1] https://igraph.org [2] https://graph-tool.skewed.de
NetworkX 3.0 - create, manipulate, and study complex networks in Python - https://news.ycombinator.com/item?id=34321135 - Jan 2023 (55 comments)
[1] https://sourceforge.net/projects/electricdss/ [2] https://matpower.org
I’m working on the distribution side, I take my graph data from the inputs for power flow: cyme, synergi etc
Any idea why that is?
From my experience as an electrical engineer working for a distribution network:
* The traditional approach to network planning: take your edge cases (e.g. winter peak demand), and apply your engineering knowledge and intuition to manually study the most onerous outage conditions.
* This will vary on where you are in the world, but networks tend to have a good amount of slack built in.
* As networks become more complex, and the cost of computing has fallen, it's more feasible to automate contingency analysis (think about the number of different outage combinations for an N-2 scenario).
FWIW, the internal tools that I work on makes use of networkx to determine contingency cases.
This is only the steady state analysis, but there's also dynamics done when looking at specific generators also to look at a generator's response to fluctuations in voltage and frequency to ensure stability within certain operating conditions (weakening of the grid, rapid change in voltage or freq).
If they were wishy washy they were probably limited to doing distribution where you are assuming a single strong source (swing bus) at the substation and it's not your responsibility to think too much about adjusting the system behavior based off of changes in transmission (usually)
It's closer to an unstable chaotic system which needs constant balancing and tweaking.