Skip to content

Graphs

124 built-in function(s) in this category.

  • AcyclicGraphQ — AcyclicGraphQ[g] gives True if g has no cycle, following directed edges forwards and undirected edges either way: a forest when undirected, a DAG when directed. u->v together with v->u is a cycle. (Stable)
  • AdjacencyGraph — AdjacencyGraph[m] builds a graph on vertices 1..n from a 0/1 adjacency matrix m (undirected if m is symmetric, else directed). (Stable)
  • AdjacencyList — AdjacencyList[g] gives the adjacency list of g; AdjacencyList[g,v] gives the vertices adjacent to v (successors for directed edges). (Stable)
  • AdjacencyMatrix — AdjacencyMatrix[g] gives the 0/1 adjacency matrix of g (symmetric for undirected graphs). (Stable)
  • BetweennessCentrality — BetweennessCentrality[g] gives for each vertex v the sum over pairs of other vertices s, t of the fraction of shortest s-t paths passing through v (unordered pairs for undirected graphs, ordered pairs for directed ones). Brandes' algorithm; edge weights are ignored, as in Wolfram. Mixed graphs are not supported. (Stable)
  • BipartiteGraphQ — BipartiteGraphQ[g] gives True if the vertices of g split into two sets with every edge running between them (edge direction is ignored). (Stable)
  • CanonicalGraph — CanonicalGraph[g] gives a canonical form of g on vertices 1..n: two graphs are isomorphic iff their canonical graphs are identical. (Stable)
  • CirculantGraph — CirculantGraph[n, j] gives the circulant graph on n vertices with i joined to i+j and i-j (mod n); CirculantGraph[n, {j1, j2, ...}] uses every jump ji. (Stable)
  • ClosenessCentrality — ClosenessCentrality[g] gives, for each vertex v, r/s where r is the number of vertices reachable from v and s the sum of their distances from v (0 if v reaches none). Uses EdgeWeight as lengths. (Stable)
  • CompleteGraph — CompleteGraph[n] gives the complete graph on n vertices. CompleteGraph[{n1, n2, ...}] gives the complete multipartite graph with parts of sizes n1, n2, .... (Stable)
  • CompleteGraphQ — CompleteGraphQ[g] gives True if every pair of distinct vertices of g is joined by an edge in both directions (an undirected edge, or directed edges both ways). CompleteGraphQ[g, vlist] tests the subgraph induced by vlist; False if some element of vlist is not a vertex of g. (Stable)
  • CompleteKaryTree — CompleteKaryTree[n] gives the complete binary tree with n levels; CompleteKaryTree[n, k] the complete k-ary tree with n levels. (Stable)
  • ConnectedComponents — ConnectedComponents[g] gives the connected components of g: the strongly connected components when g has directed edges (listed with no edge from a component to a later one), else the components, largest first. ConnectedComponents[g, {v1, ...}] keeps only those containing some vi. (Stable)
  • ConnectedGraphQ — ConnectedGraphQ[g] gives True if g is connected (strongly connected when g has directed edges). (Stable)
  • CycleGraph — CycleGraph[n] gives the cycle graph on n vertices. (Stable)
  • DegreeCentrality — DegreeCentrality[g] gives the list of vertex degrees of g; DegreeCentrality[g, "In"] and [g, "Out"] count incoming and outgoing edges. In a mixed graph an undirected edge counts as one edge in each direction. (Stable)
  • DirectedGraph — DirectedGraph[g] replaces each undirected edge u<->v of g by the pair u->v, v->u (weights duplicated). DirectedGraph[g, "Acyclic"] instead orients each undirected edge from the vertex earlier in VertexList to the later one, giving a DAG for undirected g. (Stable)
  • DirectedGraphQ — DirectedGraphQ[g] gives True if g has at least one edge and all edges of g are directed. An edgeless graph counts as undirected. (Stable)
  • EccentricityCentrality — EccentricityCentrality[g] gives 1/VertexEccentricity[g, v] for each vertex v (0 when the eccentricity is 0). Uses EdgeWeight as lengths. (Stable)
  • EdgeAdd — EdgeAdd[g, e] adds the edge e to g; EdgeAdd[g, {e1, ...}] adds several. Edges may be written u->v / DirectedEdge[u,v] or u<->v / UndirectedEdge[u,v]; endpoints not yet in g become new vertices (appended). A new edge gets weight 1 in a weighted graph. Adding a self-loop or an edge g already has (a multigraph) is left unevaluated. (Stable)
  • EdgeBetweennessCentrality — EdgeBetweennessCentrality[g] gives for each edge, in EdgeList order, the sum over ordered pairs of vertices s, t of the fraction of shortest s-t paths using that edge. Uses EdgeWeight as lengths. (Stable)
  • EdgeConnectivity — EdgeConnectivity[g] gives the minimum total weight of edges whose removal disconnects g (strongly, for directed graphs); EdgeConnectivity[g, s, t] gives the minimum s-t edge cut weight. EdgeWeight is used when present, else each edge counts 1. (Stable)
  • EdgeCount — EdgeCount[g] gives the number of edges in the graph g. (Stable)
  • EdgeCoverQ — EdgeCoverQ[g, elist] gives True if elist is a set of edges of g touching every vertex of g. (Stable)
  • EdgeDelete — EdgeDelete[g, e] removes the edge e from g; EdgeDelete[g, {e1, ...}] removes several (each must be an edge of g, else the call stays unevaluated; an undirected edge matches either orientation); EdgeDelete[g, patt] removes every edge matching patt. Vertices, order and the remaining weights are kept. (Stable)
  • EdgeIndex — EdgeIndex[g, e] gives the position of the edge e in EdgeList[g] (an undirected edge matches either orientation; u->v and u<->v sugar are accepted); EdgeIndex[g, {e1, ...}] gives a list of positions. (Stable)
  • EdgeList — EdgeList[g] gives the list of edges of the graph g. (Stable)
  • EdgeQ — EdgeQ[g, e] gives True if e is an edge of the graph g. u->v means DirectedEdge[u,v] and u<->v UndirectedEdge[u,v]; an undirected edge matches in either orientation, and direction must agree. (Stable)
  • EdgeRules — EdgeRules[g] gives the edges of g as a list of rules u -> v (undirected edges too), in EdgeList order. (Stable)
  • EdgeWeight — EdgeWeight[g] gives the weights of g's edges, in EdgeList order. Defaults to all 1s if g was built without an EdgeWeight option. (Stable)
  • EdgeWeightedGraphQ — EdgeWeightedGraphQ[g] gives True if g carries edge weights (EdgeWeight). (Stable)
  • EigenvectorCentrality — EigenvectorCentrality[g] gives the eigenvector centrality of each vertex, computed per strongly connected component (each component of k > 1 vertices weighted by k - 1, total 1; isolated vertices 0). EigenvectorCentrality[g, "In"] (default) uses incoming edges, [g, "Out"] outgoing ones. Edge weights are ignored. (Stable)
  • EmptyGraphQ — EmptyGraphQ[g] gives True if g is a graph with no edges (it may have vertices), and False otherwise. (Stable)
  • EulerianGraphQ — EulerianGraphQ[g] gives True if g has a cycle using every edge exactly once: all degrees even (undirected) or in-degree = out-degree (directed), with all edges in one connected component. Left unevaluated for mixed graphs. (Stable)
  • FindClique — FindClique[g] gives {c} with c a maximum clique of g. FindClique[g, k] finds a maximal clique of at most k vertices, [g, {k}] of exactly k, [g, {kmin, kmax}] within the range; a third argument n (or All) gives up to n such cliques. For directed graphs a clique needs edges both ways. Exact branch and bound with colouring bounds. (Stable)
  • FindCycle — FindCycle[g] finds a cycle of g, as {list of edges}, or {}. FindCycle[g, k] finds a cycle of length at most k, FindCycle[g, {k}] of length exactly k, FindCycle[g, {kmin, kmax}] of length in that range; FindCycle[g, kspec, n] finds at most n (n an integer or All). Each cycle is reported once. Length-bounded searches are exhaustive and give up (unevaluated) after 5*10^7 steps; use TimeConstrained to bound them. (Stable)
  • FindEdgeCover — FindEdgeCover[g] gives a minimum edge cover of g: a smallest set of edges touching every vertex. Gives {} when g has an isolated vertex (no edge cover exists). (Stable)
  • FindEdgeCut — FindEdgeCut[g] gives a minimum set of edges whose removal disconnects g (strongly, for directed graphs); FindEdgeCut[g, s, t] gives a minimum s-t edge cut. Uses EdgeWeight as capacity when present. Edges are returned in EdgeList order. (Stable)
  • FindEulerianCycle — FindEulerianCycle[g] gives {c}, an Eulerian cycle c of g as a list of edges (Hierholzer's algorithm, linear time), or {} if there is none. Only FindEulerianCycle[g] and FindEulerianCycle[g, 1] are supported; mixed graphs are left unevaluated. (Stable)
  • FindGraphIsomorphism — FindGraphIsomorphism[g1, g2] gives {assoc}, an isomorphism from g1 to g2 as an association of vertices, or {} if the graphs are not isomorphic. FindGraphIsomorphism[g1, g2, n] / [g1, g2, All] gives up to n / all isomorphisms. (Stable)
  • FindHamiltonianCycle — FindHamiltonianCycle[g] gives {c} with c a Hamiltonian cycle of g as a list of edges, or {} if there is none. FindHamiltonianCycle[g, n] / [g, All] gives up to n / all Hamiltonian cycles. Exact backtracking with pruning; unevaluated if the search budget is exhausted. (Stable)
  • FindHamiltonianPath — FindHamiltonianPath[g] gives a Hamiltonian path of g as a vertex list, or {} if there is none; FindHamiltonianPath[g, s, t] one from s to t. Exact; unevaluated if the search budget is exhausted. (Stable)
  • FindIndependentEdgeSet — FindIndependentEdgeSet[g] gives a maximum independent edge set (maximum matching) of g, ignoring edge direction. Hopcroft-Karp for bipartite graphs, Edmonds' blossom algorithm otherwise. (Stable)
  • FindIndependentVertexSet — FindIndependentVertexSet[g] gives {s} with s a maximum independent vertex set of g. FindIndependentVertexSet[g, k] finds a maximal independent set of at most k vertices, [g, {k}] of exactly k, [g, {kmin, kmax}] within the range; a third argument n (or All) gives up to n such sets. Exact; unevaluated if the search budget is exhausted. (Stable)
  • FindKClique — FindKClique[g, k] gives {c} with c a largest k-clique of g: a vertex set whose members are pairwise within distance k. (Stable)
  • FindMaximumFlow — FindMaximumFlow[g, s, t] gives the value of a maximum flow from s to t (s and t may be lists of sources and sinks). FindMaximumFlow[g, s, t, "prop"] gives "FlowValue", "FlowMatrix" (dense n x n matrix of edge flows) or "EdgeList" (edges carrying flow, oriented along it). Capacities come from the EdgeCapacity -> {c1, ...} option (EdgeList order), else from g's own EdgeCapacity, else 1; EdgeWeight is ignored; VertexCapacity -> {c1, ...} caps the flow through each vertex. Undirected edges carry flow either way. Dinic's algorithm; exact for integer capacities. (Stable)
  • FindMinimumCut — FindMinimumCut[g] gives {value, {part1, part2}}: a partition of the vertices minimizing the total weight of the edges from part1 to part2 (EdgeWeight when present, else 1). For directed graphs part1 is the source side. Nagamochi-Ibaraki for undirected graphs, max flows for directed ones. (Stable)
  • FindPath — FindPath[g, s, t] finds a path from s to t, as {vertex list}, or {} (depth-first, linear time). FindPath[g, s, t, k] finds a path with at most k edges, FindPath[g, s, t, {k}] exactly k, {kmin, kmax} in a range; FindPath[g, s, t, kspec, n] finds at most n paths (n or All), shortest first. Length-bounded searches give up (unevaluated) after 5*10^7 steps. (Stable)
  • FindShortestPath — FindShortestPath[g,s,t] gives a shortest path from s to t as a list of vertices ({} if none). (Stable)
  • FindSpanningTree — FindSpanningTree[g] gives a spanning tree (forest) of g as a graph: a minimum spanning tree when g has EdgeWeight (an arborescence for a directed graph), else a breadth-first one. FindSpanningTree[{g, v}] gives the tree grown from vertex v. (Stable)
  • FindVertexColoring — FindVertexColoring[g] gives a MINIMAL vertex colouring of g as a list of integers in VertexList order: the number of distinct colours equals the chromatic number, and no edge joins two vertices of equal colour. Minimality is proven by exact search (Wolfram's "BacktrackingDS" method) seeded by DSATUR upper and clique lower bounds. Exact colouring is NP-hard, so there are two guards, and exceeding EITHER returns the expression UNEVALUATED -- never a valid-but-larger colouring. (1) Graphs of more than 128 vertices are refused outright. (2) The search gives up after 8 million nodes, on the order of 100 seconds; a node count rather than a clock, so the answer does not depend on how fast the host is. To bound how long a call may take, wrap it in TimeConstrained -- that is the intended lever, and the search polls for the deadline so it is honoured; the 8-million-node ceiling is a last-resort backstop for an unattended run, not the responsiveness mechanism. Cost is driven by DENSITY, not by vertex count: a sparse 128-vertex graph answers instantly, while a dense one may exhaust the budget and refuse. FindVertexColoring[g, {c1, ...}] and FindVertexColoring[g, l] are not implemented. (Partial)
  • FindVertexCover — FindVertexCover[g] gives a minimum vertex cover of g (a smallest vertex set touching every edge), exact by branch and reduce. Stays unevaluated if optimality cannot be proven within the search budget. (Stable)
  • FindVertexCut — FindVertexCut[g] gives a minimum set of vertices whose removal disconnects the underlying undirected graph of g (n-1 vertices for a complete graph); FindVertexCut[g, s, t] gives a minimum set separating s from t ({} when they are adjacent). (Stable)
  • GlobalClusteringCoefficient — GlobalClusteringCoefficient[g] gives 3 x (number of triangles) / (number of connected triples) of g, exactly. (Stable)
  • Graph — Graph[v, e] represents a graph with vertices v and edges e. Graph[e] derives the vertices from the edge list. Edges are DirectedEdge[u,v] or UndirectedEdge[u,v]; u->v and u<->v are accepted as shorthand. Graph[e, opts] and Graph[v, e, opts] attach per-edge lists, matched to e by position: EdgeWeight -> {w1, ...} and EdgeCapacity -> {c1, ...}. Simple graphs only: no self-loops or parallel edges. (Stable)
  • GraphAutomorphismGroup — GraphAutomorphismGroup[g] gives the automorphism group of g as PermutationGroup[{Cycles[...], ...}] acting on vertex positions. (Stable)
  • GraphCenter — GraphCenter[g] gives the vertices of g with minimum eccentricity; {} unless g is (strongly) connected. (Stable)
  • GraphComplement — GraphComplement[g] gives the complement of g: the same vertices, with an edge wherever g has none. For a directed or mixed g the complement is directed (u->v present iff no edge of g leads from u to v). Edges are in row-major VertexList order; weights are dropped. (Stable)
  • GraphDensity — GraphDensity[g] gives the number of edges of g divided by the number of possible edges: (directed edges + 2 undirected edges)/(n(n-1)). (Stable)
  • GraphDiameter — GraphDiameter[g] gives the greatest distance between two vertices of g: the maximum vertex eccentricity. Infinity unless g is (strongly) connected. (Stable)
  • GraphDifference — GraphDifference[g1, g2] gives the graph on the union of the vertex sets whose edges are those of g1 not in g2, in canonical order. Weights are dropped. (Stable)
  • GraphDisjointUnion — GraphDisjointUnion[g1, g2, ...] gives the disjoint union of the gi, with vertices relabelled 1, 2, ..., n (g1's first, in VertexList order). Weights are dropped. (Stable)
  • GraphDistance — GraphDistance[g, s, t] gives the length of a shortest path from s to t (Infinity if unreachable). GraphDistance[g, s] gives the list of distances from s to every vertex, in VertexList order. Edge weights are used as lengths when g has EdgeWeight. (Stable)
  • GraphDistanceMatrix — GraphDistanceMatrix[g] gives the matrix of shortest-path distances between all pairs of vertices of g, rows and columns in VertexList order; entry {i, j} is the distance from vertex i to vertex j (Infinity if unreachable). GraphDistanceMatrix[g, d] keeps only distances at most d. Integers for unweighted graphs, machine reals when g has EdgeWeight (edge weights as lengths). (Stable)
  • GraphIntersection — GraphIntersection[g1, g2, ...] gives the graph on the union of the vertex sets whose edges are those common to all the gi, in canonical order. Weights are dropped. (Stable)
  • GraphPeriphery — GraphPeriphery[g] gives the vertices of g with maximum eccentricity; {} unless g is (strongly) connected. (Stable)
  • GraphPlot — GraphPlot[g, opts] gives a Graphics object drawing the graph g (or a list of rules {u -> v, ...}). The default layout is deterministic: tidy layered trees for branching forests, layered drawings for DAGs, stress majorization otherwise, with components packed side by side. Options: GraphLayout -> "StressEmbedding" | "SpringElectricalEmbedding" | "CircularEmbedding" | "LayeredEmbedding" | "BipartiteEmbedding" | "GridEmbedding"; VertexCoordinates -> {{x,y}, ...} or {v -> {x,y}, ...}; VertexLabels -> None | "Name" | Automatic | {v -> lbl, ...}; GraphHighlight -> {v, e, ...} (red, thicker); VertexStyle and EdgeStyle -> a colour or {item -> colour, ...}; EdgeLabels -> "EdgeWeight" | {e -> lbl}; VertexSize -> d (diameter in edge lengths). Directed edges get arrowheads that stop at the target vertex. Other options (ImageSize, PlotLabel, ...) pass through to Graphics. (Stable)
  • GraphQ — GraphQ[g] gives True if g is a valid graph, and False otherwise. (Stable)
  • GraphRadius — GraphRadius[g] gives the minimum vertex eccentricity of g. Infinity unless g is (strongly) connected. (Stable)
  • GraphTriangleCount — GraphTriangleCount[g] gives the number of triangles of an undirected graph g, or of directed 3-cycles of a directed graph. O(m^1.5) degree-ordered triangle listing. (Stable)
  • GraphUnion — GraphUnion[g1, g2, ...] gives the graph whose vertices and edges are the unions of those of the gi (vertices in canonical order; an undirected edge equals its reversal). Weights are dropped. (Stable)
  • GridGraph — GridGraph[{m, n}] gives the m x n grid graph; GridGraph[{n1, ..., nk}] the k-dimensional grid. The first coordinate varies fastest in the vertex numbering. (Stable)
  • HITSCentrality — HITSCentrality[g] gives {h, a}: h is the principal eigenvector of A^T A (per block of vertices sharing in-neighbours, each block of k > 1 vertices weighted k - 1, total 1) and a = A h, with A the adjacency matrix (Wolfram's convention). Edge weights are ignored. (Stable)
  • HamiltonianGraphQ — HamiltonianGraphQ[g] gives True if g has a Hamiltonian cycle. Exact; unevaluated if the search budget is exhausted. (Stable)
  • HararyGraph — HararyGraph[k, n] gives the Harary graph: a k-connected graph on n vertices with the minimum number of edges (k >= 2, n > k). (Stable)
  • HypercubeGraph — HypercubeGraph[n] gives the n-dimensional hypercube graph on 2^n vertices. (Stable)
  • IncidenceMatrix — IncidenceMatrix[g] gives the vertex-edge incidence matrix of g (oriented: -1 tail, +1 head for directed edges). (Stable)
  • IndependentEdgeSetQ — IndependentEdgeSetQ[g, elist] gives True if elist is a set of edges of g no two of which share a vertex. (Stable)
  • IndependentVertexSetQ — IndependentVertexSetQ[g, vlist] gives True if no two vertices of vlist are adjacent in g. (Stable)
  • IndexGraph — IndexGraph[g] replaces the vertices of g by 1, 2, ..., n (in VertexList order); IndexGraph[g, r] by r, r+1, ..., r+n-1. Edge weights are kept. (Stable)
  • IsomorphicGraphQ — IsomorphicGraphQ[g1, g2, ...] gives True if all the graphs are isomorphic. Colour refinement with individualization-refinement search. (Stable)
  • KaryTree — KaryTree[n] gives a binary tree with n vertices; KaryTree[n, k] a k-ary tree with n vertices, vertices numbered in breadth-first order. (Stable)
  • KatzCentrality — KatzCentrality[g, a] gives the Katz centrality x = a A^T x + 1 of each vertex; KatzCentrality[g, a, b] uses b (a number or a list) in place of 1. Edge weights are ignored. (Stable)
  • KirchhoffMatrix — KirchhoffMatrix[g] gives the Kirchhoff (Laplacian) matrix D - A of g, with D the diagonal matrix of vertex degrees (incident edges) and A the adjacency matrix. Dense (Wolfram returns a SparseArray); weights are ignored. (Stable)
  • LineGraph — LineGraph[g] gives the line graph of g: one vertex per edge (numbered by EdgeList position); undirected edges sharing an endpoint are joined, and for directed g, edge i -> edge j when i ends where j starts. Mixed graphs are left unevaluated. (Stable)
  • LocalClusteringCoefficient — LocalClusteringCoefficient[g] gives for each vertex the fraction of pairs of its neighbours that are adjacent (exact); LocalClusteringCoefficient[g, v] gives it for v. For directed graphs, directed 3-cycles through v over in/out neighbour pairs. (Stable)
  • LoopFreeGraphQ — LoopFreeGraphQ[g] gives True if g is a graph with no self-loops -- every valid Mathilda graph -- and False otherwise. (Stable)
  • MeanClusteringCoefficient — MeanClusteringCoefficient[g] gives the mean of the local clustering coefficients of g, exactly. (Stable)
  • MeanGraphDistance — MeanGraphDistance[g] gives the mean distance over all ordered pairs of distinct vertices of g: exact for unweighted graphs, a machine real for weighted ones, Infinity unless g is (strongly) connected. (Stable)
  • MixedGraphQ — MixedGraphQ[g] gives True if g has both directed and undirected edges. (Stable)
  • NeighborhoodGraph — NeighborhoodGraph[g, v] gives the subgraph of g induced by v and its neighbours; NeighborhoodGraph[g, v, k] by the vertices within distance k of v (k a non-negative integer or Infinity), edge direction ignored. NeighborhoodGraph[g, {v1, ...}, k] uses several centres. Vertices: the centres, then each centre's new vertices in VertexList order. (Stable)
  • PageRankCentrality — PageRankCentrality[g, a] gives the PageRank of each vertex with damping factor a (default 0.85): x = a P^T x + (1-a)/n, where a vertex with no outgoing edge links to every vertex; the entries sum to 1. Edge weights are ignored. (Stable)
  • PathGraph — PathGraph[n] gives the path on n vertices; PathGraph[{v1,...}] the path over the given vertices. (Stable)
  • PathGraphQ — PathGraphQ[g] gives True if g is a path: connected with at least one vertex and, if undirected, every degree at most 2 and one edge fewer than vertices; if directed, every in- and out-degree at most 1. Mixed graphs are never paths. (Stable)
  • PetersenGraph — PetersenGraph[] gives the Petersen graph; PetersenGraph[n, k] the generalized Petersen graph: inner vertices 1..n with i joined to i+k (mod n), outer cycle n+1..2n, and spokes i to n+i. (Stable)
  • PlanarGraphQ — PlanarGraphQ[g] gives True if g can be drawn in the plane without edge crossings. Linear-time left-right planarity test; gives False for non-graphs. (Stable)
  • RandomGraph — RandomGraph[{n, m}] gives a random undirected graph with n vertices and m edges. RandomGraph[{n, m}, k] gives a list of k such graphs; memory use grows with k. (Stable)
  • ReverseGraph — ReverseGraph[g] reverses every directed edge of g; undirected edges, the edge order and the weights are kept. (Stable)
  • SimpleGraphQ — SimpleGraphQ[g] gives True if g is a graph with no self-loops or parallel edges -- every valid Mathilda graph -- and False otherwise. (Stable)
  • StarGraph — StarGraph[n] gives the star on n vertices: the hub 1 joined to each of the n-1 leaves 2..n. (Stable)
  • StronglyConnectedComponents — StronglyConnectedComponents[g] gives the strongly connected components of g (following edge directions), in the same order as ConnectedComponents on a directed graph. (Stable)
  • Subgraph — Subgraph[g, {v1, v2, ...}] gives the subgraph of g induced by the listed vertices (elements that are not vertices of g are ignored); Subgraph[g, patt] uses the vertices matching patt. Vertices come in the order given; edges in lower-triangular order of that vertex order. Edge weights are kept. (Stable)
  • TopologicalSort — TopologicalSort[g] gives the vertices of the directed acyclic graph g ordered so that u precedes v for every edge u->v; ties go to the vertex earlier in VertexList[g]. TopologicalSort[{v->w, ...}] uses the rules as the graph. Left unevaluated if g has a cycle or an undirected edge. (Stable)
  • TreeGraphQ — TreeGraphQ[g] gives True if g is a tree: at least one vertex, connected, and with no cycles, ignoring edge direction. A disconnected forest is not a tree. (Stable)
  • TuranGraph — TuranGraph[n, k] gives the Turan graph: the complete k-partite graph on n vertices with parts as equal as possible. (Stable)
  • UndirectedGraph — UndirectedGraph[g] gives the undirected graph underlying g: u->v and v->u become the single edge u<->v, whose weight is the sum of theirs. Edges are oriented and ordered by VertexList position. An undirected g is returned unchanged. (Stable)
  • UndirectedGraphQ — UndirectedGraphQ[g] gives True if every edge of g is undirected (including when g has no edges), and False otherwise. (Stable)
  • VertexAdd — VertexAdd[g, v] adds the vertex v to the graph g; VertexAdd[g, {v1, v2, ...}] adds several. Vertices already present are ignored; new ones are appended in order. Edge weights are kept. (Stable)
  • VertexConnectivity — VertexConnectivity[g] gives the minimum number of vertices whose removal disconnects g. (Stable)
  • VertexCount — VertexCount[g] gives the number of vertices in the graph g. (Stable)
  • VertexCoverQ — VertexCoverQ[g, vlist] gives True if every edge of g has an endpoint in vlist. (Stable)
  • VertexDegree — VertexDegree[g] gives the list of vertex degrees; VertexDegree[g,v] gives the degree of vertex v. (Stable)
  • VertexDelete — VertexDelete[g, v] removes the vertex v and its incident edges from g; VertexDelete[g, {v1, ...}] removes several (each must be a vertex of g, else the call stays unevaluated); VertexDelete[g, patt] removes every vertex matching patt. Vertex and edge order and edge weights are kept. (Stable)
  • VertexEccentricity — VertexEccentricity[g, v] gives the largest distance from v to any vertex reachable from v. With EdgeWeight the weights are lengths and, as in Wolfram, a vertex v cannot reach makes it Infinity. (Stable)
  • VertexInDegree — VertexInDegree[g] / VertexInDegree[g,v] gives in-degrees (incoming directed edges; undirected edges count for both). (Stable)
  • VertexIndex — VertexIndex[g, v] gives the position of the vertex v in VertexList[g]; VertexIndex[g, {v1, ...}] gives a list of positions. (Stable)
  • VertexList — VertexList[g] gives the list of vertices of the graph g. (Stable)
  • VertexOutDegree — VertexOutDegree[g] / VertexOutDegree[g,v] gives out-degrees (outgoing directed edges; undirected edges count for both). (Stable)
  • VertexQ — VertexQ[g, v] gives True if v is a vertex of the graph g (compared structurally, as by SameQ), and False otherwise. (Stable)
  • VertexReplace — VertexReplace[g, {v1 -> w1, ...}] replaces vertices of g according to the rules (applied to each vertex as by Replace, so patterns work). Vertices mapped together merge; a merge that would create a self-loop or a parallel edge leaves the call unevaluated. Edge weights are kept. (Stable)
  • WeaklyConnectedComponents — WeaklyConnectedComponents[g] gives the weakly connected components of g (edge directions ignored), largest first. WeaklyConnectedComponents[g, {v1, ...}] keeps only those containing some vi. (Stable)
  • WeightedAdjacencyMatrix — WeightedAdjacencyMatrix[g] gives the adjacency matrix of g with each entry the corresponding edge's weight (0 where there is no edge). Equal to AdjacencyMatrix[g] when g has no EdgeWeight. (Stable)
  • WeightedGraphQ — WeightedGraphQ[g] gives True if g carries edge weights (EdgeWeight). (Stable)
  • WheelGraph — WheelGraph[n] gives the wheel graph with n vertices: vertex 1 joined to every vertex of the cycle 2, ..., n. (Stable)