Graph and Network Algorithms
Graphs model the connections in a network and are widely applicable to a variety of physical, biological, and information systems. You can use graphs to model the neurons in a brain, the flight patterns of an airline, and much more. The structure of a graph is comprised of “nodes” and “edges”. Each node represents an entity, and each edge represents a connection between two nodes. For more information, see Directed and Undirected Graphs.
Modify Nodes and Edges
|Add new node to graph
|Remove node from graph
|Add new edge to graph
|Remove edge from graph
|Reverse edge directions
|Number of nodes in graph
|Number of edges in graph
|Locate node in graph
|Locate edge in graph
|Number of edges between two nodes
|Reorder graph nodes
|Measure node importance
|Connected graph components
|Biconnected graph components
|Block-cut tree graph
|Topological order of directed acyclic graph
|Determine if graph is acyclic
|Determine whether two graphs are isomorphic
|Compute isomorphism between two graphs
|Determine whether graph has multiple edges
|Reduce multigraph to simple graph
Traversals, Shortest Paths, and Cycles
|Breadth-first graph search
|Depth-first graph search
|Shortest path between two single nodes
|Shortest path tree from node
|Shortest path distances of all node pairs
|Find all paths between two graph nodes (Since R2021a)
|Maximum flow in graph
|Minimum spanning tree of graph
|Determine whether graph contains cycles (Since R2021a)
|Find all cycles in graph (Since R2021a)
|Fundamental cycle basis of graph (Since R2021a)
|Graph plot for directed and undirected graphs
|Graph plot appearance and behavior
- Directed and Undirected Graphs
Introduction to directed and undirected graphs.
- Graphs and Matrices
This example shows an application of sparse matrices and explains the relationship between graphs and matrices.
- Modify Nodes and Edges of Existing Graph
This example shows how to access and modify the nodes and/or edges in a
digraphobject using the
- Add Graph Node Names, Edge Weights, and Other Attributes
This example shows how to add attributes to the nodes and edges in graphs created using
- Graph Plotting and Customization
This example shows how to plot graphs, and then customize the display to add labels or highlighting to the graph nodes and edges.
- Label Graph Nodes and Edges
This example shows how to add and customize labels on graph nodes and edges.
- Add Node Properties to Graph Plot Data Tips
This example shows how to customize
GraphPlotdata tips to display extra node properties of a graph.
- Visualize Breadth-First and Depth-First Search
This example shows how to define a function that visualizes the results of
dfsearchby highlighting the nodes and edges of a graph.