Skip to content

Basic Inspection

Ed Scheinerman edited this page Sep 28, 2020 · 14 revisions

Basic Inspection Functions

  • NV(G): the number of vertices.
  • NE(G): the number of edges.
  • vlist(G): list containing the vertices.
  • elist(G): list containing the edges.

Note that G.V and G.E give direct access to the vertex and edge sets of the graph. Look but don't touch.


  • has(G,v): is v a vertex of G?
  • has(G,v,w): is (v,w) an edge of G?
  • get_edge(G,u,v) returns either (u,v) or (v,u) matching how the edge is represented in G.E. An error is thrown if u and v are not adjacent vertices of G.
  • adjacency(G): the adjacency matrix of G.

  • neighbors(G,v): list of v's neighbors. Also G[v].
  • deg(G,v): degree of vertex v.
  • deg(G): sorted list of vertex degrees.

See also deg_hist.


  • twins(G,u,v) returns true if vertices u and v are twins in G. The definition of twins is that G[u]-v == G[v]-u. This is an equivalence relation.
  • twins(G) returns a partition of the vertex set of G into twin classes.
Clone this wiki locally