User:Jansen9/sandbox

NetworkX is a Python library for studying graphs and networks. NetworkX is free software released under the BSD-new license.

History
NetworkX began development in 2002 by Aric A. Hagberg, Daniel A. Schult, and Pieter J. Swart. It is supported by the National Nuclear Security Administration of the U.S. Department of Energy at Los Alamos National Laboratory.

The package was crafted with the aim of creating tools to analyze data and intervention strategies for controlling the epidemic spread of disease, while also exploring the structure and dynamics of more general social, biological, and infrastructural systems.

Inspired by Guido van Rossum's 1998 essay on Python graph representation, NetworkX made its public debut at the 2004 SciPy annual conference. In April of 2005, NetworkX was made available as open source software.

Several Python packages focusing on graph theory, including igraph, graph-tool, and numerous others, are available. As of April 2024, NetworkX had over 50 million downloads, surpassing the download count of the second most popular package, igraph, by more than 50-fold. This substantial adoption rate could potentially be attributed to NetworkX's early release and its continued evolution within the SciPy ecosystem.

In 2008, SageMath, an open source mathematics system, incorporated NetworkX into its package and added support for more graphing algorithms and functions.

Features

 * Classes for graphs and digraphs.
 * Conversion of graphs to and from several formats.
 * Ability to construct random graphs or construct them incrementally.
 * Ability to find subgraphs, cliques, k-cores.
 * Explore adjacency, degree, diameter, radius, center, betweenness, etc.
 * Draw networks in 2D and 3D.

Overview
Graphs, in this context, represent collections of vertices (nodes) and edges (connections) between them. NetworkX provides support for several types of graphs, each suited for different applications and scenarios.

Directed Graphs (DiGraph)
Directed graphs, or DiGraphs, consist of nodes connected by directed edges. In a directed graph, edges have a direction indicating the flow or relationship between nodes.

Undirected Graphs (Graph)
Undirected graphs, simply referred to as graphs in NetworkX, are graphs where edges have no inherent direction. The connections between nodes are symmetrical, meaning if node A is connected to node B, then node B is also connected to node A.

MultiGraphs
MultiGraphs allow multiple edges between the same pair of nodes. In other words, MultiGraphs permit parallel edges, where more than one edge can exist between two nodes.

MultiDiGraphs
MultiDiGraphs are directed graphs that allow multiple directed edges between the same pair of nodes. Similar to MultiGraphs, MultiDiGraphs enable the modeling of scenarios where multiple directed relationships exist between nodes.

Suitability
NetworkX is suitable for operation on large real-world graphs: e.g., graphs in excess of 10 million nodes and 100 million edges. Due to its dependence on a pure-Python "dictionary of dictionary" data structure, NetworkX is a reasonably efficient, very scalable, highly portable framework for network and social network analysis.

Applications
NetworkX was designed to be easy to use and learn, as well as a powerful and sophisticated tool for network analysis. It is used widely on many levels, ranging from computer science and data analysis education to large-scale scientific studies.

NetworkX has applications in any field that studies data as graphs or networks, such as mathematics, physics, biology, computer science and social science. The nodes in a NetworkX graph can be specialized to hold any data, and the data stored in edges is arbitrary, further making it widely applicable to different fields. It is able to read in networks from data and randomly generate networks with specified qualities. This allows it to be used to explore changes across wide amounts of networks. The figure below demonstrates a simple example of the software's ability to create and modify variations across large amounts of networks.



NetworkX has many network and graph analysis algorithms, aiding in a wide array of data analysis purposes. One important example of this is its various options for shortest path algorithms. The following algorithms are included in NetworkX, with time complexities given the number of vertices (V) and edges (E) in the graph :


 * Dijkstra: O((V+E) log V)
 * Bellman-Ford: O(V * E)
 * Goldberg-Radzik: O(V * E)
 * Johnson: O(V^2 log(V) + VE)
 * Floyd Warshall: O(V^3)
 * A*: O((V+E) log V)

An example of the use of NetworkX graph algorithms can be seen in a 2018 study, in which it was used to analyze the resilience of livestock production networks to the spread of epidemics. The study used a computer model to predict and study trends in epidemics throughout American hog production networks, taking into account all livestock industry roles. In the study, NetworkX was used to find information on degree, shortest paths, clustering, and k-cores as the model introduced infections and simulated their spread. This was then used to determine which networks are most susceptible to epidemics.

In addition to network creation and analysis, NetworkX also has many visualization capabilities. It provides hooks into Matplotlib and GraphViz for 2D visuals, and VTK and UbiGraph for 3D visuals. This makes the package useful in easily demonstrating and reporting network analysis and data, and allows for the simplification of networks for visual processing.

Integration
NetworkX is integrated into SageMath.