Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

Graph Construction & Representation

Graphs are first-class citizens in the Wolfram Language and can be used as input, output, in programs, and in documents. Undirected and directed graphs are treated uniformly and support a number of standard properties for vertices and edges. Importantly, graphs also support custom properties for modeling or computational flexibility. Graphs can be converted to a number of different representations, including matrices. Graphs can be exported with high fidelity to numerous file formats.
 Graphs can be constructed in a variety of ways. They can be built from vertices and edges directly in a symbolic form. They can come from built-in curated collections of theoretical or empirical graphs. Special graphs can be generated from parametric specifications. Random graphs following a variety of graph distributions allow you to build simulated internets or citation graphs and test algorithms. Graphs can be fully specified by several types of matrices, or they can be imported from numerous supported file formats. Graphs can also be constructed in several steps by performing operations on graphs.


Graph represent a general graph, or create it from vertices and edges

UndirectedEdge an undirected edge ()

DirectedEdge a directed edge ()

Basic Properties

VertexList, EdgeList the list of vertices and edges in the graph

VertexIndex, EdgeIndex the index for a vertex or edge in a graph

AdjacencyList  ▪  IncidenceList  ▪  EdgeRules

Matrix Representations »

AdjacencyMatrix, AdjacencyGraph matrix representation and graph construction

IncidenceMatrix  ▪  KirchhoffMatrix  ▪  WeightedAdjacencyMatrix  ▪  ...

Graph Properties »

PropertyValue get and set vertex or edge property values

EdgeWeight  ▪  VertexWeight  ▪  EdgeCapacity  ▪  VertexCapacity  ▪  ...

Import and Export Graphs

Import, Export import and export graphs

"GraphML"  ▪  "GXL"  ▪  "Graphlet"  ▪  "Pajek"  ▪  "TGF"  ▪  "DOT"  ▪  "DIMACS"  ▪  "Graph6"  ▪  "Sparse6"  ▪  "LEDA"

Curated Graphs

GraphData collection of theoretical graphs

ExampleData collection of empirical graphs

SocialMediaData graph data from social sites (Facebook, Twitter, )

PolyhedronData  ▪  ChemicalData  ▪  WordData  ▪  CountryData  ▪  IsotopeData

Parametric Graphs

CompleteGraph generate a complete or a complete k-partite graph

ButterflyGraph  ▪  CirculantGraph  ▪  CompleteKaryTree  ▪  CycleGraph  ▪  DeBruijnGraph  ▪  GridGraph  ▪  HararyGraph  ▪  HypercubeGraph  ▪  KaryTree  ▪  KnightTourGraph  ▪  PetersenGraph  ▪  StarGraph  ▪  TuranGraph  ▪  WheelGraph

Structured Graphs

PathGraph general directed or undirected path

TreeGraph general directed or undirected tree

PlanarGraph general directed or undirected planar graph

Graphs from Data

RelationGraph generate a graph based on data and a relation

NearestNeighborGraph generate the k-nearest neighbor graph for general elements

NestGraph generate a nested function graph

ClusteringTree generate a tree from hierarchical clustering of elements

Random Graphs »

RandomGraph generate random graphs following a graph distribution

GraphPropertyDistribution  ▪  UniformGraphDistribution  ▪  ...

Operations and Modifications of Graphs »

Subgraph extract subgraphs

NeighborhoodGraph  ▪  GraphUnion  ▪  VertexAdd  ▪  EdgeAdd  ▪  ...