Introduction to graphs
======================

The graphs package provides graph and digraph data structure for Maxima. Graphs and digraphs are simple (have no multiple edges nor loops), although digraphs can have a directed edge from U to V and a directed edge from V to U.

Internally graphs are represented by adjacency lists and implemented as a lisp structures. Vertices are identified by their ids (an id is an integer). Edges/arcs are represented by lists of length 2. Labels can be assigned to vertices of graphs/digraphs and weights can be assigned to edges/arcs of graphs/digraphs.

There is a draw_graph function for drawing graphs. Graphs are drawn using a force based vertex positioning algorithm. draw_graph can also use graphviz programs available from http://www.graphviz.org. draw_graph is based on the maxima draw package.

To use the graphs package, first load it with load(graphs).

Share packages Package graphs

Functions and Variables for graphs
==================================

Building graphs
---------------

 -- Function: create_graph (V_LIST, E_LIST)
 -- Function: create_graph (N, E_LIST)
 -- Function: create_graph (V_LIST, E_LIST, DIRECTED)
     Creates a new graph on the set of vertices V_LIST and with edges E_LIST.

     V_LIST is a list of vertices ([v1, v2,..., vn]) or a list of vertices together with vertex labels ([[v1,l1], [v2,l2],..., [vn,ln]]).

     N is the number of vertices. Vertices will be identified by integers from 0 to n-1.

     E_LIST is a list of edges ([e1, e2,..., em]) or a list of edges together with edge-weights ([[e1, w1], ..., [em, wm]]).

     If DIRECTED is not false, a directed graph will be returned.

     Example 1: create a cycle on 3 vertices:

          (%i1) load (graphs)$
          (%i2) g : create_graph([1,2,3], [[1,2], [2,3], [1,3]])$
          (%i3) print_graph(g)$
          Graph on 3 vertices with 3 edges.
          Adjacencies:
            3 :  1  2
            2 :  3  1
            1 :  3  2

     Example 2: create a cycle on 3 vertices with edge weights:

          (%i1) load (graphs)$
          (%i2) g : create_graph([1,2,3], [[[1,2], 1.0], [[2,3], 2.0],
                                    [[1,3], 3.0]])$
          (%i3) print_graph(g)$
          Graph on 3 vertices with 3 edges.
          Adjacencies:
            3 :  1  2
            2 :  3  1
            1 :  3  2

     Example 3: create a directed graph:

          (%i1) load (graphs)$
          (%i2) d : create_graph(
                  [1,2,3,4],
                  [
                   [1,3], [1,4],
                   [2,3], [2,4]
                  ],
                  'directed = true)$
          (%i3) print_graph(d)$
          Digraph on 4 vertices with 4 arcs.
          Adjacencies:
            4 :
            3 :
            2 :  4  3
            1 :  4  3

     Package graphs

 -- Function: copy_graph (G)
     Returns a copy of the graph G.

     Package graphs Package graphs - constructions

 -- Function: circulant_graph (N, D)
     Returns the circulant graph with parameters N and D.

     Example:

          (%i1) load (graphs)$
          (%i2) g : circulant_graph(10, [1,3])$
          (%i3) print_graph(g)$
          Graph on 10 vertices with 20 edges.
          Adjacencies:
            9 :  2  6  0  8
            8 :  1  5  9  7
            7 :  0  4  8  6
            6 :  9  3  7  5
            5 :  8  2  6  4
            4 :  7  1  5  3
            3 :  6  0  4  2
            2 :  9  5  3  1
            1 :  8  4  2  0
            0 :  7  3  9  1

     Package graphs Package graphs - constructions

 -- Function: clebsch_graph ()
     Returns the Clebsch graph.

     Package graphs Package graphs - constructions

 -- Function: complement_graph (G)
     Returns the complement of the graph G.

     Package graphs Package graphs - constructions

 -- Function: complete_bipartite_graph (N, M)
     Returns the complete bipartite graph on N+M vertices.

     Package graphs Package graphs - constructions

 -- Function: complete_graph (N)
     Returns the complete graph on N vertices.

     Package graphs Package graphs - constructions

 -- Function: cycle_digraph (N)
     Returns the directed cycle on N vertices.

     Package graphs Package graphs - constructions

 -- Function: cycle_graph (N)
     Returns the cycle on N vertices.

     Package graphs Package graphs - constructions

 -- Function: cuboctahedron_graph (N)
     Returns the cuboctahedron graph.

     Package graphs Package graphs - constructions

 -- Function: cube_graph (N)
     Returns the N-dimensional cube.

     Package graphs Package graphs - constructions

 -- Function: dodecahedron_graph ()
     Returns the dodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: empty_graph (N)
     Returns the empty graph on N vertices.

     Package graphs Package graphs - constructions

 -- Function: flower_snark (N)
     Returns the flower graph on 4N vertices.

     Example:

          (%i1) load (graphs)$
          (%i2) f5 : flower_snark(5)$
          (%i3) chromatic_index(f5);
          (%o3)                           4

     Package graphs Package graphs - constructions

 -- Function: from_adjacency_matrix (A)
     Returns the graph represented by its adjacency matrix A.

     Package graphs Package graphs - constructions

 -- Function: frucht_graph ()
     Returns the Frucht graph.

     Package graphs Package graphs - constructions

 -- Function: graph_product (G1, G1)
     Returns the direct product of graphs G1 and G2.

     Example:

          (%i1) load (graphs)$
          (%i2) grid : graph_product(path_graph(3), path_graph(4))$
          (%i3) draw_graph(grid)$

     Package graphs Package graphs - constructions

 -- Function: graph_union (G1, G1)
     Returns the union (sum) of graphs G1 and G2.

     Package graphs Package graphs - constructions

 -- Function: grid_graph (N, M)
     Returns the N X M grid.

     Package graphs Package graphs - constructions

 -- Function: great_rhombicosidodecahedron_graph ()
     Returns the great rhombicosidodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: great_rhombicuboctahedron_graph ()
     Returns the great rhombicuboctahedron graph.

     Package graphs Package graphs - constructions

 -- Function: grotzch_graph ()
     Returns the Grotzch graph.

     Package graphs Package graphs - constructions

 -- Function: heawood_graph ()
     Returns the Heawood graph.

     Package graphs Package graphs - constructions

 -- Function: icosahedron_graph ()
     Returns the icosahedron graph.

     Package graphs Package graphs - constructions

 -- Function: icosidodecahedron_graph ()
     Returns the icosidodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: induced_subgraph (V, G)
     Returns the graph induced on the subset V of vertices of the graph G.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) V : [0,1,2,3,4]$
          (%i4) g : induced_subgraph(V, p)$
          (%i5) print_graph(g)$
          Graph on 5 vertices with 5 edges.
          Adjacencies:
            4 :  3  0
            3 :  2  4
            2 :  1  3
            1 :  0  2
            0 :  1  4

     Package graphs Package graphs - constructions

 -- Function: line_graph (G)
     Returns the line graph of the graph G.

     Package graphs Package graphs - constructions

 -- Function: make_graph (VRT, F)
 -- Function: make_graph (VRT, F, ORIENTED)
     Creates a graph using a predicate function F.

     VRT is a list/set of vertices or an integer. If VRT is an integer, then vertices of the graph will be integers from 1 to VRT.

     F is a predicate function. Two vertices A and B will be connected if f(a,b)=true.

     If DIRECTED is not FALSE, then the graph will be directed.

     Example 1:

          (%i1) load(graphs)$
          (%i2) g : make_graph(powerset({1,2,3,4,5}, 2), disjointp)$
          (%i3) is_isomorphic(g, petersen_graph());
          (%o3)                         true
          (%i4) get_vertex_label(1, g);
          (%o4)                        {1, 2}

     Example 2:

          (%i1) load(graphs)$
          (%i2) f(i, j) := is (mod(j, i)=0)$
          (%i3) g : make_graph(20, f, directed=true)$
          (%i4) out_neighbors(4, g);
          (%o4)                    [8, 12, 16, 20]
          (%i5) in_neighbors(18, g);
          (%o5)                    [1, 2, 3, 6, 9]

     Package graphs Package graphs - constructions

 -- Function: mycielski_graph (G)
     Returns the mycielskian graph of the graph G.

     Package graphs Package graphs - constructions

 -- Function: new_graph ()
     Returns the graph with no vertices and no edges.

     Package graphs Package graphs - constructions

 -- Function: path_digraph (N)
     Returns the directed path on N vertices.

     Package graphs Package graphs - constructions

 -- Function: path_graph (N)
     Returns the path on N vertices.

     Package graphs Package graphs - constructions

 -- Function: petersen_graph ()
 -- Function: petersen_graph (N, D)
     Returns the petersen graph P_{N,D}. The default values for N and D are n=5 and d=2.

     Package graphs Package graphs - constructions

 -- Function: random_bipartite_graph (A, B, P)
     Returns a random bipartite graph on a+b vertices. Each edge is present with probability P.

     Package graphs Package graphs - constructions

 -- Function: random_digraph (N, P)
     Returns a random directed graph on N vertices. Each arc is present with probability P.

     Package graphs Package graphs - constructions

 -- Function: random_regular_graph (N)
 -- Function: random_regular_graph (N, D)
     Returns a random D-regular graph on N vertices. The default value for D is d=3.

     Package graphs Package graphs - constructions

 -- Function: random_graph (N, P)
     Returns a random graph on N vertices. Each edge is present with probability P.

     Package graphs Package graphs - constructions

 -- Function: random_graph1 (N, M)
     Returns a random graph on N vertices and random M edges.

     Package graphs Package graphs - constructions

 -- Function: random_network (N, P, W)
     Returns a random network on N vertices. Each arc is present with probability P and has a weight in the range [0,w]. The function returns a list [network, source, sink].

     Example:

          (%i1) load (graphs)$
          (%i2) [net, s, t] : random_network(50, 0.2, 10.0);
          (%o2)                   [DIGRAPH, 50, 51]
          (%i3) max_flow(net, s, t)$
          (%i4) first(%);
          (%o4)                   27.65981397932507

     Package graphs Package graphs - constructions

 -- Function: random_tournament (N)
     Returns a random tournament on N vertices.

     Package graphs Package graphs - constructions

 -- Function: random_tree (N)
     Returns a random tree on N vertices.

     Package graphs Package graphs - constructions

 -- Function: small_rhombicosidodecahedron_graph ()
     Returns the small rhombicosidodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: small_rhombicuboctahedron_graph ()
     Returns the small rhombicuboctahedron graph.

     Package graphs Package graphs - constructions

 -- Function: snub_cube_graph ()
     Returns the snub cube graph.

     Package graphs Package graphs - constructions

 -- Function: snub_dodecahedron_graph ()
     Returns the snub dodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: truncated_cube_graph ()
     Returns the truncated cube graph.

     Package graphs Package graphs - constructions

 -- Function: truncated_dodecahedron_graph ()
     Returns the truncated dodecahedron graph.

     Package graphs Package graphs - constructions

 -- Function: truncated_icosahedron_graph ()
     Returns the truncated icosahedron graph.

     Package graphs Package graphs - constructions

 -- Function: truncated_tetrahedron_graph ()
     Returns the truncated tetrahedron graph.

     Package graphs Package graphs - constructions

 -- Function: tutte_graph ()
     Returns the Tutte graph.

     Package graphs Package graphs - constructions

 -- Function: underlying_graph (G)
     Returns the underlying graph of the directed graph G.

     Package graphs Package graphs - constructions

 -- Function: wheel_graph (N)
     Returns the wheel graph on N+1 vertices.

     Package graphs Package graphs - constructions

Graph properties
----------------

 -- Function: adjacency_matrix (GR)
     Returns the adjacency matrix of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) c5 : cycle_graph(4)$
          (%i3) adjacency_matrix(c5);
                                   [ 0  1  0  1 ]
                                   [            ]
                                   [ 1  0  1  0 ]
          (%o3)                    [            ]
                                   [ 0  1  0  1 ]
                                   [            ]
                                   [ 1  0  1  0 ]

     Package graphs Package graphs - properties

 -- Function: average_degree (GR)
     Returns the average degree of vertices in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) average_degree(grotzch_graph());
                                         40
          (%o2)                          --
                                         11

     Package graphs Package graphs - properties

 -- Function: biconected_components (GR)
     Returns the (vertex sets of) 2-connected components of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph(
                      [1,2,3,4,5,6,7],
                      [
                       [1,2],[2,3],[2,4],[3,4],
                       [4,5],[5,6],[4,6],[6,7]
                      ])$
          (%i3) biconnected_components(g);
          (%o3)        [[6, 7], [4, 5, 6], [1, 2], [2, 3, 4]]

     Package graphs Package graphs - properties

 -- Function: bipartition (GR)
     Returns a bipartition of the vertices of the graph GR or an empty list if GR is not bipartite.

     Example:

          (%i1) load (graphs)$
          (%i2) h : heawood_graph()$
          (%i3) [A,B]:bipartition(h);
          (%o3)  [[8, 12, 6, 10, 0, 2, 4], [13, 5, 11, 7, 9, 1, 3]]
          (%i4) draw_graph(h, show_vertices=A, program=circular)$

     Package graphs Package graphs - properties

 -- Function: chromatic_index (GR)
     Returns the chromatic index of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) chromatic_index(p);
          (%o3)                           4

     Package graphs Package graphs - properties

 -- Function: chromatic_number (GR)
     Returns the chromatic number of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) chromatic_number(cycle_graph(5));
          (%o2)                           3
          (%i3) chromatic_number(cycle_graph(6));
          (%o3)                           2

     Package graphs Package graphs - properties

 -- Function: clear_edge_weight (E, GR)
     Removes the weight of the edge  E in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph(3, [[[0,1], 1.5], [[1,2], 1.3]])$
          (%i3) get_edge_weight([0,1], g);
          (%o3)                          1.5
          (%i4) clear_edge_weight([0,1], g)$
          (%i5) get_edge_weight([0,1], g);
          (%o5)                           1

     Package graphs Package graphs - properties

 -- Function: clear_vertex_label (V, GR)
     Removes the label of the vertex V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph([[0,"Zero"], [1, "One"]], [[0,1]])$
          (%i3) get_vertex_label(0, g);
          (%o3)                         Zero
          (%i4) clear_vertex_label(0, g);
          (%o4)                         done
          (%i5) get_vertex_label(0, g);
          (%o5)                         false

     Package graphs Package graphs - properties

 -- Function: connected_components (GR)
     Returns the (vertex sets of) connected components of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g: graph_union(cycle_graph(5), path_graph(4))$
          (%i3) connected_components(g);
          (%o3)            [[1, 2, 3, 4, 0], [8, 7, 6, 5]]

     Package graphs Package graphs - properties

 -- Function: diameter (GR)
     Returns the diameter of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) diameter(dodecahedron_graph());
          (%o2)                           5

     Package graphs Package graphs - properties

 -- Function: edge_coloring (GR)
     Returns an optimal coloring of the edges of the graph GR.

     The function returns the chromatic index and a list representing the coloring of the edges of GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) [ch_index, col] : edge_coloring(p);
          (%o3) [4, [[[0, 5], 3], [[5, 7], 1], [[0, 1], 1], [[1, 6], 2],
          [[6, 8], 1], [[1, 2], 3], [[2, 7], 4], [[7, 9], 2], [[2, 3], 2],
          [[3, 8], 3], [[5, 8], 2], [[3, 4], 1], [[4, 9], 4], [[6, 9], 3],
          [[0, 4], 2]]]
          (%i4) assoc([0,1], col);
          (%o4)                           1
          (%i5) assoc([0,5], col);
          (%o5)                           3

     Package graphs Package graphs - properties

 -- Function: degree_sequence (GR)
     Returns the list of vertex degrees of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) degree_sequence(random_graph(10, 0.4));
          (%o2)            [2, 2, 2, 2, 2, 2, 3, 3, 3, 3]

     Package graphs Package graphs - properties

 -- Function: edge_connectivity (GR)
     Returns the edge-connectivity of the graph GR.

     See also min_edge_cut.

     Package graphs Package graphs - properties

 -- Function: edges (GR)
     Returns the list of edges (arcs) in a (directed) graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) edges(complete_graph(4));
          (%o2)   [[2, 3], [1, 3], [1, 2], [0, 3], [0, 2], [0, 1]]

     Package graphs Package graphs - properties

 -- Function: get_edge_weight (E, GR)
 -- Function: get_edge_weight (E, GR, IFNOT)
     Returns the weight of the edge E in the graph GR.

     If there is no weight assigned to the edge, the function returns 1. If the edge is not present in the graph, the function signals an error or returns the optional argument IFNOT.

     Example:

          (%i1) load (graphs)$
          (%i2) c5 : cycle_graph(5)$
          (%i3) get_edge_weight([1,2], c5);
          (%o3)                           1
          (%i4) set_edge_weight([1,2], 2.0, c5);
          (%o4)                         done
          (%i5) get_edge_weight([1,2], c5);
          (%o5)                          2.0

     Package graphs Package graphs - properties

 -- Function: get_vertex_label (V, GR)
     Returns the label of the vertex V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph([[0,"Zero"], [1, "One"]], [[0,1]])$
          (%i3) get_vertex_label(0, g);
          (%o3)                         Zero

     Package graphs Package graphs - properties

 -- Function: graph_charpoly (GR, X)
     Returns the characteristic polynomial (in variable X) of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) graph_charpoly(p, x), factor;
                                             5        4
          (%o3)               (x - 3) (x - 1)  (x + 2)

     Package graphs Package graphs - properties

 -- Function: graph_center (GR)
     Returns the center of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : grid_graph(5,5)$
          (%i3) graph_center(g);
          (%o3)                         [12]

     Package graphs Package graphs - properties

 -- Function: graph_eigenvalues (GR)
     Returns the eigenvalues of the graph GR. The function returns eigenvalues in the same format as maxima eigenvalue function.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) graph_eigenvalues(p);
          (%o3)               [[3, - 2, 1], [1, 4, 5]]

     Package graphs Package graphs - properties

 -- Function: graph_periphery (GR)
     Returns the periphery of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : grid_graph(5,5)$
          (%i3) graph_periphery(g);
          (%o3)                    [24, 20, 4, 0]

     Package graphs Package graphs - properties

 -- Function: graph_size (GR)
     Returns the number of edges in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) graph_size(p);
          (%o3)                          15

     Package graphs Package graphs - properties

 -- Function: graph_order (GR)
     Returns the number of vertices in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) graph_order(p);
          (%o3)                          10

     Package graphs Package graphs - properties

 -- Function: girth (GR)
     Returns the length of the shortest cycle in GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : heawood_graph()$
          (%i3) girth(g);
          (%o3)                           6

     Package graphs Package graphs - properties

 -- Function: hamilton_cycle (GR)
     Returns the Hamilton cycle of the graph GR or an empty list if GR is not hamiltonian.

     Example:

          (%i1) load (graphs)$
          (%i2) c : cube_graph(3)$
          (%i3) hc : hamilton_cycle(c);
          (%o3)              [7, 3, 2, 6, 4, 0, 1, 5, 7]
          (%i4) draw_graph(c, show_edges=vertices_to_cycle(hc))$

     Package graphs Package graphs - properties

 -- Function: hamilton_path (GR)
     Returns the Hamilton path of the graph GR or an empty list if GR does not have a Hamilton path.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) hp : hamilton_path(p);
          (%o3)            [0, 5, 7, 2, 1, 6, 8, 3, 4, 9]
          (%i4) draw_graph(p, show_edges=vertices_to_path(hp))$

     Package graphs Package graphs - properties

 -- Function: isomorphism (GR1, GR2)

     Returns a an isomorphism between graphs/digraphs GR1 and GR2. If GR1 and GR2 are not isomorphic, it returns an empty list.

     Example:

          (%i1) load (graphs)$
          (%i2) clk5:complement_graph(line_graph(complete_graph(5)))$
          (%i3) isomorphism(clk5, petersen_graph());
          (%o3) [9 -> 0, 2 -> 1, 6 -> 2, 5 -> 3, 0 -> 4, 1 -> 5, 3 -> 6,
                                                    4 -> 7, 7 -> 8, 8 -> 9]

     Package graphs Package graphs - properties

 -- Function: in_neighbors (V, GR)
     Returns the list of in-neighbors of the vertex V in the directed graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : path_digraph(3)$
          (%i3) in_neighbors(2, p);
          (%o3)                          [1]
          (%i4) out_neighbors(2, p);
          (%o4)                          []

     Package graphs Package graphs - properties

 -- Function: is_biconnected (GR)
     Returns true if GR is 2-connected and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_biconnected(cycle_graph(5));
          (%o2)                         true
          (%i3) is_biconnected(path_graph(5));
          (%o3)                         false

     Package graphs Package graphs - properties

 -- Function: is_bipartite (GR)
     Returns true if GR is bipartite (2-colorable) and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_bipartite(petersen_graph());
          (%o2)                         false
          (%i3) is_bipartite(heawood_graph());
          (%o3)                         true

     Package graphs Package graphs - properties

 -- Function: is_connected (GR)
     Returns true if the graph GR is connected and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_connected(graph_union(cycle_graph(4), path_graph(3)));
          (%o2)                         false

     Package graphs Package graphs - properties

 -- Function: is_digraph (GR)
     Returns true if GR is a directed graph and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_digraph(path_graph(5));
          (%o2)                         false
          (%i3) is_digraph(path_digraph(5));
          (%o3)                         true

     Package graphs Package graphs - properties

 -- Function: is_edge_in_graph (E, GR)
     Returns true if E is an edge (arc) in the (directed) graph G and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) c4 : cycle_graph(4)$
          (%i3) is_edge_in_graph([2,3], c4);
          (%o3)                         true
          (%i4) is_edge_in_graph([3,2], c4);
          (%o4)                         true
          (%i5) is_edge_in_graph([2,4], c4);
          (%o5)                         false
          (%i6) is_edge_in_graph([3,2], cycle_digraph(4));
          (%o6)                         false

     Package graphs Package graphs - properties

 -- Function: is_graph (GR)
     Returns true if GR is a graph and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_graph(path_graph(5));
          (%o2)                         true
          (%i3) is_graph(path_digraph(5));
          (%o3)                         false

     Package graphs Package graphs - properties

 -- Function: is_graph_or_digraph (GR)
     Returns true if GR is a graph or a directed graph and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_graph_or_digraph(path_graph(5));
          (%o2)                         true
          (%i3) is_graph_or_digraph(path_digraph(5));
          (%o3)                         true

     Package graphs Package graphs - properties

 -- Function: is_isomorphic (GR1, GR2)

     Returns true if graphs/digraphs GR1 and GR2 are isomorphic and false otherwise.

     See also isomorphism.

     Example:

          (%i1) load (graphs)$
          (%i2) clk5:complement_graph(line_graph(complete_graph(5)))$
          (%i3) is_isomorphic(clk5, petersen_graph());
          (%o3)                         true

     Package graphs Package graphs - properties

 -- Function: is_planar (GR)

     Returns true if GR is a planar graph and false otherwise.

     The algorithm used is the Demoucron's algorithm, which is a quadratic time algorithm.

     Example:

          (%i1) load (graphs)$
          (%i2) is_planar(dodecahedron_graph());
          (%o2)                         true
          (%i3) is_planar(petersen_graph());
          (%o3)                         false
          (%i4) is_planar(petersen_graph(10,2));
          (%o4)                         true

     Package graphs Package graphs - properties

 -- Function: is_sconnected (GR)
     Returns true if the directed graph GR is strongly connected and false otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_sconnected(cycle_digraph(5));
          (%o2)                         true
          (%i3) is_sconnected(path_digraph(5));
          (%o3)                         false

     Package graphs Package graphs - properties

 -- Function: is_vertex_in_graph (V, GR)
     Returns true if V is a vertex in the graph G and false  otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) c4 : cycle_graph(4)$
          (%i3) is_vertex_in_graph(0, c4);
          (%o3)                         true
          (%i4) is_vertex_in_graph(6, c4);
          (%o4)                         false

     Package graphs Package graphs - properties

 -- Function: is_tree (GR)
     Returns true if GR is a tree and false  otherwise.

     Example:

          (%i1) load (graphs)$
          (%i2) is_tree(random_tree(4));
          (%o2)                         true
          (%i3) is_tree(graph_union(random_tree(4), random_tree(5)));
          (%o3)                         false

     Package graphs Package graphs - properties

 -- Function: laplacian_matrix (GR)
     Returns the laplacian matrix of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) laplacian_matrix(cycle_graph(5));
                             [  2   - 1   0    0   - 1 ]
                             [                         ]
                             [ - 1   2   - 1   0    0  ]
                             [                         ]
          (%o2)              [  0   - 1   2   - 1   0  ]
                             [                         ]
                             [  0    0   - 1   2   - 1 ]
                             [                         ]
                             [ - 1   0    0   - 1   2  ]

     Package graphs Package graphs - properties

 -- Function: max_clique (GR)
     Returns a maximum clique of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : random_graph(100, 0.5)$
          (%i3) max_clique(g);
          (%o3)          [6, 12, 31, 36, 52, 59, 62, 63, 80]

     Package graphs Package graphs - properties

 -- Function: max_degree (GR)
     Returns the maximal degree of vertices of the graph GR and a vertex of maximal degree.

     Example:

          (%i1) load (graphs)$
          (%i2) g : random_graph(100, 0.02)$
          (%i3) max_degree(g);
          (%o3)                        [6, 79]
          (%i4) vertex_degree(95, g);
          (%o4)                           2

     Package graphs Package graphs - properties

 -- Function: max_flow (NET, S, T)
     Returns a maximum flow through the network NET with the source S and the sink T.

     The function returns the value of the maximal flow and a list representing the weights of the arcs in the optimal flow.

     Example:

          (%i1) load (graphs)$
          (%i2) net : create_graph(
            [1,2,3,4,5,6],
            [[[1,2], 1.0],
             [[1,3], 0.3],
             [[2,4], 0.2],
             [[2,5], 0.3],
             [[3,4], 0.1],
             [[3,5], 0.1],
             [[4,6], 1.0],
             [[5,6], 1.0]],
            directed=true)$
          (%i3) [flow_value, flow] : max_flow(net, 1, 6);
          (%o3) [0.7, [[[1, 2], 0.5], [[1, 3], 0.2], [[2, 4], 0.2],
          [[2, 5], 0.3], [[3, 4], 0.1], [[3, 5], 0.1], [[4, 6], 0.3],
          [[5, 6], 0.4]]]
          (%i4) fl : 0$
          (%i5) for u in out_neighbors(1, net)
               do fl : fl + assoc([1, u], flow)$
          (%i6) fl;
          (%o6)                          0.7

     Package graphs Package graphs - properties

 -- Function: max_independent_set (GR)
     Returns a maximum independent set of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) d : dodecahedron_graph()$
          (%i3) mi : max_independent_set(d);
          (%o3)             [0, 3, 5, 9, 10, 11, 18, 19]
          (%i4) draw_graph(d, show_vertices=mi)$

     Package graphs Package graphs - properties

 -- Function: max_matching (GR)
     Returns a maximum matching of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) d : dodecahedron_graph()$
          (%i3) m : max_matching(d);
          (%o3) [[5, 7], [8, 9], [6, 10], [14, 19], [13, 18], [12, 17],
                                         [11, 16], [0, 15], [3, 4], [1, 2]]
          (%i4) draw_graph(d, show_edges=m)$

     Package graphs Package graphs - properties

 -- Function: min_degree (GR)
     Returns the minimum degree of vertices of the graph GR and a vertex of minimum degree.

     Example:

          (%i1) load (graphs)$
          (%i2) g : random_graph(100, 0.1)$
          (%i3) min_degree(g);
          (%o3)                        [3, 49]
          (%i4) vertex_degree(21, g);
          (%o4)                           9

     Package graphs Package graphs - properties

 -- Function: min_edge_cut (GR)
     Returns the minimum edge cut in the graph GR.

     See also edge_connectivity.

     Package graphs Package graphs - properties

 -- Function: min_vertex_cover (GR)
     Returns the minimum vertex cover of the graph GR.

     Package graphs Package graphs - properties

 -- Function: min_vertex_cut (GR)
     Returns the minimum vertex cut in the graph GR.

     See also vertex_connectivity.

     Package graphs Package graphs - properties

 -- Function: minimum_spanning_tree (GR)
     Returns the minimum spanning tree of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : graph_product(path_graph(10), path_graph(10))$
          (%i3) t : minimum_spanning_tree(g)$
          (%i4) draw_graph(g, show_edges=edges(t))$

     Package graphs Package graphs - properties

 -- Function: neighbors (V, GR)
     Returns the list of neighbors of the vertex V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : petersen_graph()$
          (%i3) neighbors(3, p);
          (%o3)                       [4, 8, 2]

     Package graphs Package graphs - properties

 -- Function: odd_girth (GR)
     Returns the length of the shortest odd cycle in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : graph_product(cycle_graph(4), cycle_graph(7))$
          (%i3) girth(g);
          (%o3)                           4
          (%i4) odd_girth(g);
          (%o4)                           7

     Package graphs Package graphs - properties

 -- Function: out_neighbors (V, GR)
     Returns the list of out-neighbors of the vertex V in the directed graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : path_digraph(3)$
          (%i3) in_neighbors(2, p);
          (%o3)                          [1]
          (%i4) out_neighbors(2, p);
          (%o4)                          []

     Package graphs Package graphs - properties

 -- Function: planar_embedding (GR)

     Returns the list of facial walks in a planar embedding of GR and false if GR is not a planar graph.

     The graph GR must be biconnected.

     The algorithm used is the Demoucron's algorithm, which is a quadratic time algorithm.

     Example:

          (%i1) load (graphs)$
          (%i2) planar_embedding(grid_graph(3,3));
          (%o2) [[3, 6, 7, 8, 5, 2, 1, 0], [4, 3, 0, 1], [3, 4, 7, 6],
                                                [8, 7, 4, 5], [1, 2, 5, 4]]

     Package graphs Package graphs - properties

 -- Function: print_graph (GR)
     Prints some information about the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) c5 : cycle_graph(5)$
          (%i3) print_graph(c5)$
          Graph on 5 vertices with 5 edges.
          Adjacencies:
            4 :  0  3
            3 :  4  2
            2 :  3  1
            1 :  2  0
            0 :  4  1
          (%i4) dc5 : cycle_digraph(5)$
          (%i5) print_graph(dc5)$
          Digraph on 5 vertices with 5 arcs.
          Adjacencies:
            4 :  0
            3 :  4
            2 :  3
            1 :  2
            0 :  1
          (%i6) out_neighbors(0, dc5);
          (%o6)                          [1]

     Package graphs

 -- Function: radius (GR)
     Returns the radius of the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) radius(dodecahedron_graph());
          (%o2)                           5

     Package graphs Package graphs - properties

 -- Function: set_edge_weight (E, W, GR)
     Assigns the weight W to the edge E in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph([1, 2], [[[1,2], 1.2]])$
          (%i3) get_edge_weight([1,2], g);
          (%o3)                          1.2
          (%i4) set_edge_weight([1,2], 2.1, g);
          (%o4)                         done
          (%i5) get_edge_weight([1,2], g);
          (%o5)                          2.1

     Package graphs Package graphs - properties

 -- Function: set_vertex_label (V, L, GR)
     Assigns the label L to the vertex V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : create_graph([[1, "One"], [2, "Two"]], [[1,2]])$
          (%i3) get_vertex_label(1, g);
          (%o3)                          One
          (%i4) set_vertex_label(1, "oNE", g);
          (%o4)                         done
          (%i5) get_vertex_label(1, g);
          (%o5)                          oNE

     Package graphs Package graphs - properties

 -- Function: shortest_path (U, V, GR)
     Returns the shortest path from U to V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) d : dodecahedron_graph()$
          (%i3) path : shortest_path(0, 7, d);
          (%o3)                   [0, 1, 19, 13, 7]
          (%i4) draw_graph(d, show_edges=vertices_to_path(path))$

     Package graphs Package graphs - properties

 -- Function: shortest_weighted_path (U, V, GR)
     Returns the length of the shortest weighted path and the shortest weighted path from U to V in the graph GR.

     The length of a weighted path is the sum of edge weights of edges in the path. If an edge has no weight, then it has a default weight 1.

     Example:

          (%i1) load (graphs)$
          (%i2) g: petersen_graph(20, 2)$
          (%i3) for e in edges(g) do set_edge_weight(e, random(1.0), g)$
          (%i4) shortest_weighted_path(0, 10, g);
          (%o4) [2.575143920268482, [0, 20, 38, 36, 34, 32, 30, 10]]

     Package graphs Package graphs - properties

 -- Function: strong_components (GR)
     Returns the strong components of a directed graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) t : random_tournament(4)$
          (%i3) strong_components(t);
          (%o3)                 [[1], [0], [2], [3]]
          (%i4) vertex_out_degree(3, t);
          (%o4)                           3

     Package graphs Package graphs - properties

 -- Function: topological_sort (DAG)

     Returns a topological sorting of the vertices of a directed graph DAG or an empty list if DAG is not a directed acyclic graph.

     Example:

          (%i1) load (graphs)$
          (%i2) g:create_graph(
                   [1,2,3,4,5],
                   [
                    [1,2], [2,5], [5,3],
                    [5,4], [3,4], [1,3]
                   ],
                   directed=true)$
          (%i3) topological_sort(g);
          (%o3)                    [1, 2, 5, 3, 4]

     Package graphs Package graphs - properties

 -- Function: vertex_connectivity (G)
     Returns the vertex connectivity of the graph G.

     See also min_vertex_cut.

     Package graphs Package graphs - properties

 -- Function: vertex_degree (V, GR)
     Returns the degree of the vertex V in the graph GR.

     Package graphs Package graphs - properties

 -- Function: vertex_distance (U, V, GR)
     Returns the length of the shortest path between U and V in the (directed) graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) d : dodecahedron_graph()$
          (%i3) vertex_distance(0, 7, d);
          (%o3)                           4
          (%i4) shortest_path(0, 7, d);
          (%o4)                   [0, 1, 19, 13, 7]

     Package graphs Package graphs - properties

 -- Function: vertex_eccentricity (V, GR)

     Returns the eccentricity of the vertex V in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g:cycle_graph(7)$
          (%i3) vertex_eccentricity(0, g);
          (%o3)                           3

     Package graphs Package graphs - properties

 -- Function: vertex_in_degree (V, GR)
     Returns the in-degree of the vertex V in the directed graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p5 : path_digraph(5)$
          (%i3) print_graph(p5)$
          Digraph on 5 vertices with 4 arcs.
          Adjacencies:
            4 :
            3 :  4
            2 :  3
            1 :  2
            0 :  1
          (%i4) vertex_in_degree(4, p5);
          (%o4)                           1
          (%i5) in_neighbors(4, p5);
          (%o5)                          [3]

     Package graphs Package graphs - properties

 -- Function: vertex_out_degree (V, GR)
     Returns the out-degree of the vertex V in the directed graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) t : random_tournament(10)$
          (%i3) vertex_out_degree(0, t);
          (%o3)                           2
          (%i4) out_neighbors(0, t);
          (%o4)                        [7, 1]

     Package graphs Package graphs - properties

 -- Function: vertices (GR)
     Returns the list of vertices in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) vertices(complete_graph(4));
          (%o2)                     [3, 2, 1, 0]

     Package graphs Package graphs - properties

 -- Function: vertex_coloring (GR)
     Returns an optimal coloring of the vertices of the graph GR.

     The function returns the chromatic number and a list representing the coloring of the vertices of GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p:petersen_graph()$
          (%i3) vertex_coloring(p);
          (%o3) [3, [[0, 2], [1, 3], [2, 2], [3, 3], [4, 1], [5, 3],
                                           [6, 1], [7, 1], [8, 2], [9, 2]]]

     Package graphs Package graphs - properties

 -- Function: wiener_index (GR)
     Returns the Wiener index of the graph GR.

     Example:

          (%i2) wiener_index(dodecahedron_graph());
          (%o2)                          500

     Package graphs Package graphs - properties

Modifying graphs
----------------

 -- Function: add_edge (E, GR)
     Adds the edge E to the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) p : path_graph(4)$
          (%i3) neighbors(0, p);
          (%o3)                          [1]
          (%i4) add_edge([0,3], p);
          (%o4)                         done
          (%i5) neighbors(0, p);
          (%o5)                        [3, 1]

     Package graphs Package graphs - modifications

 -- Function: add_edges (E_LIST, GR)
     Adds all edges in the list E_LIST to the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : empty_graph(3)$
          (%i3) add_edges([[0,1],[1,2]], g)$
          (%i4) print_graph(g)$
          Graph on 3 vertices with 2 edges.
          Adjacencies:
            2 :  1
            1 :  2  0
            0 :  1

     Package graphs Package graphs - modifications

 -- Function: add_vertex (V, GR)
     Adds the vertex V to the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g : path_graph(2)$
          (%i3) add_vertex(2, g)$
          (%i4) print_graph(g)$
          Graph on 3 vertices with 1 edges.
          Adjacencies:
            2 :
            1 :  0
            0 :  1

     Package graphs Package graphs - modifications

 -- Function: add_vertices (V_LIST, GR)
     Adds all vertices in the list V_LIST to the graph GR.

     Package graphs Package graphs - modifications

 -- Function: connect_vertices (V_LIST, U_LIST, GR)
     Connects all vertices from the list V_LIST with the vertices in the list U_LIST in the graph GR.

     V_LIST and U_LIST can be single vertices or lists of vertices.

     Example:

          (%i1) load (graphs)$
          (%i2) g : empty_graph(4)$
          (%i3) connect_vertices(0, [1,2,3], g)$
          (%i4) print_graph(g)$
          Graph on 4 vertices with 3 edges.
          Adjacencies:
            3 :  0
            2 :  0
            1 :  0
            0 :  3  2  1

     Package graphs Package graphs - modifications

 -- Function: contract_edge (E, GR)
     Contracts the edge E in the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) g: create_graph(
                8, [[0,3],[1,3],[2,3],[3,4],[4,5],[4,6],[4,7]])$
          (%i3) print_graph(g)$
          Graph on 8 vertices with 7 edges.
          Adjacencies:
            7 :  4
            6 :  4
            5 :  4
            4 :  7  6  5  3
            3 :  4  2  1  0
            2 :  3
            1 :  3
            0 :  3
          (%i4) contract_edge([3,4], g)$
          (%i5) print_graph(g)$
          Graph on 7 vertices with 6 edges.
          Adjacencies:
            7 :  3
            6 :  3
            5 :  3
            3 :  5  6  7  2  1  0
            2 :  3
            1 :  3
            0 :  3

     Package graphs Package graphs - modifications

 -- Function: remove_edge (E, GR)
     Removes the edge E from the graph GR.

     Example:

          (%i1) load (graphs)$
          (%i2) c3 : cycle_graph(3)$
          (%i3) remove_edge([0,1], c3)$
          (%i4) print_graph(c3)$
          Graph on 3 vertices with 2 edges.
          Adjacencies:
            2 :  0  1
            1 :  2
            0 :  2

     Package graphs Package graphs - modifications

 -- Function: remove_vertex (V, GR)
     Removes the vertex V from the graph GR.

     Package graphs

Reading and writing to files
----------------------------

 -- Function: dimacs_export (GR, FL)
 -- Function: dimacs_export (GR, FL, COMMENT1, ..., COMMENTN)

     Exports the graph into the file FL in the DIMACS format. Optional comments will be added to the top of the file.

     Package graphs Package graphs - io

 -- Function: dimacs_import (FL)

     Returns the graph from file FL in the DIMACS format.

     Package graphs Package graphs - io

 -- Function: graph6_decode (STR)

     Returns the graph encoded in the graph6 format in the string STR.

     Package graphs Package graphs - io

 -- Function: graph6_encode (GR)

     Returns a string which encodes the graph GR in the graph6 format.

     Package graphs Package graphs - io

 -- Function: graph6_export (GR_LIST, FL)

     Exports graphs in the list GR_LIST to the file FL in the graph6 format.

     Package graphs Package graphs - io

 -- Function: graph6_import (FL)

     Returns a list of graphs from the file FL in the graph6 format.

     Package graphs Package graphs - io

 -- Function: sparse6_decode (STR)

     Returns the graph encoded in the sparse6 format in the string STR.

     Package graphs Package graphs - io

 -- Function: sparse6_encode (GR)

     Returns a string which encodes the graph GR in the sparse6 format.

     Package graphs Package graphs - io

 -- Function: sparse6_export (GR_LIST, FL)

     Exports graphs in the list GR_LIST to the file FL in the sparse6 format.

     Package graphs Package graphs - io

 -- Function: sparse6_import (FL)

     Returns a list of graphs from the file FL in the sparse6 format.

     Package graphs Package graphs - io

Visualization
-------------

 -- Function: draw_graph (GRAPH)
 -- Function: draw_graph (GRAPH, OPTION1, ..., OPTIONK)
     Draws the graph using the draw package.

     The algorithm used to position vertices is specified by the optional argument PROGRAM. The default value is program=spring_embedding. DRAW_GRAPH can also use the graphviz programs for positioning vertices, but graphviz must be installed separately.

     Example 1:

          (%i1) load (graphs)$
          (%i2) g:grid_graph(10,10)$
          (%i3) m:max_matching(g)$
          (%i4) draw_graph(g,
             spring_embedding_depth=100,
             show_edges=m, edge_type=dots,
             vertex_size=0)$

     Example 2:

          (%i1) load (graphs)$
          (%i2) g:create_graph(16,
              [
               [0,1],[1,3],[2,3],[0,2],[3,4],[2,4],
               [5,6],[6,4],[4,7],[6,7],[7,8],[7,10],[7,11],
               [8,10],[11,10],[8,9],[11,12],[9,15],[12,13],
               [10,14],[15,14],[13,14]
              ])$
          (%i3) t:minimum_spanning_tree(g)$
          (%i4) draw_graph(
              g,
              show_edges=edges(t),
              show_edge_width=4,
              show_edge_color=green,
              vertex_type=filled_square,
              vertex_size=2
              )$

     Example 3:

          (%i1) load (graphs)$
          (%i2) g:create_graph(16,
              [
               [0,1],[1,3],[2,3],[0,2],[3,4],[2,4],
               [5,6],[6,4],[4,7],[6,7],[7,8],[7,10],[7,11],
               [8,10],[11,10],[8,9],[11,12],[9,15],[12,13],
               [10,14],[15,14],[13,14]
              ])$
          (%i3) mi : max_independent_set(g)$
          (%i4) draw_graph(
              g,
              show_vertices=mi,
              show_vertex_type=filled_up_triangle,
              show_vertex_size=2,
              edge_color=cyan,
              edge_width=3,
              show_id=true,
              text_color=brown
              )$

     Example 4:

          (%i1) load (graphs)$
          (%i2) net : create_graph(
              [0,1,2,3,4,5],
              [
               [[0,1], 3], [[0,2], 2],
               [[1,3], 1], [[1,4], 3],
               [[2,3], 2], [[2,4], 2],
               [[4,5], 2], [[3,5], 2]
              ],
              directed=true
              )$
          (%i3) draw_graph(
              net,
              show_weight=true,
              vertex_size=0,
              show_vertices=[0,5],
              show_vertex_type=filled_square,
              head_length=0.2,
              head_angle=10,
              edge_color="dark-green",
              text_color=blue
              )$

     Example 5:

          (%i1) load(graphs)$
          (%i2) g: petersen_graph(20, 2);
          (%o2)                         GRAPH
          (%i3) draw_graph(g, redraw=true, program=planar_embedding);
          (%o3)                         done

     Example 6:

          (%i1) load(graphs)$
          (%i2) t: tutte_graph();
          (%o2)                         GRAPH
          (%i3) draw_graph(t, redraw=true, fixed_vertices=[1,2,3,4,5,6,7,8,9]);
          (%o3)                         done

     Package graphs

 -- Option variable: draw_graph_program
     Default value: SPRING_EMBEDDING

     The default value for the program used to position vertices in draw_graph program.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_id
     Default value: FALSE

     If TRUE then ids of the vertices are displayed.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_label
     Default value: FALSE

     If TRUE then labels of the vertices are displayed.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: label_alignment
     Default value: CENTER

     Determines how to align the labels/ids of the vertices. Can be left, center or right.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_weight
     Default value: FALSE

     If TRUE then weights of the edges are displayed.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: vertex_type
     Default value: CIRCLE

     Defines how vertices are displayed. See the POINT_TYPE option for the draw package for possible values.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: vertex_size
     The size of vertices.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: vertex_color
     The color used for displaying vertices.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_vertices
     Default value: []

     Display selected vertices in the using a different color.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_vertex_type
     Defines how vertices specified in SHOW_VERTICES are displayed. See the POINT_TYPE option for the draw package for possible values.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_vertex_size
     The size of vertices in SHOW_VERTICES.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_vertex_color
     The color used for displaying vertices in the SHOW_VERTICES list.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: vertex_partition
     Default value: []

     A partition [[v1,v2,...],...,[vk,...,vn]] of the vertices of the graph. The vertices of each list in the partition will be drawn in a different color.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: vertex_coloring
     Specifies coloring of the vertices. The coloring COL must be specified in the format as returned by VERTEX_COLORING.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: edge_color
     The color used for displaying edges.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: edge_width
     The width of edges.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: edge_type
     Defines how edges are displayed. See the LINE_TYPE option for the draw package.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_edges
     Display edges specified in the list E_LIST using a different color.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_edge_color
     The color used for displaying edges in the SHOW_EDGES list.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_edge_width
     The width of edges in SHOW_EDGES.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: show_edge_type
     Defines how edges in SHOW_EDGES are displayed. See the LINE_TYPE option for the draw package.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: edge_partition
     A partition [[e1,e2,...],...,[ek,...,em]] of edges of the graph. The edges of each list in the partition will be drawn using a different color.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: edge_coloring
     The coloring of edges. The coloring must be specified in the format as returned by the function EDGE_COLORING.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: redraw
     Default value: FALSE

     If true, vertex positions are recomputed even if the positions have been saved from a previous drawing of the graph.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: head_angle
     Default value: 15

     The angle for the arrows displayed on arcs (in directed graphs).

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: head_length
     Default value: 0.1

     The length for the arrows displayed on arcs (in directed graphs).

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: spring_embedding_depth
     Default value: 50

     The number of iterations in the spring embedding graph drawing algorithm.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: terminal
     The terminal used for drawing (see the TERMINAL option in the draw package).

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: file_name
     The filename of the drawing if terminal is not screen.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: program
     Defines the program used for positioning vertices of the graph. Can be one of the graphviz programs (dot, neato, twopi, circ, fdp), CIRCULAR, SPRING_EMBEDDING or PLANAR_EMBEDDING. PLANAR_EMBEDDING is only available for 2-connected planar graphs. When program=spring_embedding, a set of vertices with fixed position can be specified with the FIXED_VERTICES option.

     Package graphs Package graphs - draw_graphs options

 -- draw_graph option: fixed_vertices
     Specifies a list of vertices which will have positions fixed along a regular polygon. Can be used when program=spring_embedding.

     Package graphs Package graphs - draw_graphs options

 -- Function: vertices_to_path (V_LIST)
     Converts a list V_LIST of vertices to a list of edges of the path defined by V_LIST.

     Package graphs

 -- Function: vertices_to_cycle (V_LIST)
     Converts a list V_LIST of vertices to a list of edges of the cycle defined by V_LIST.

     Package graphs