Constructions

This module provides constructions of graphs.

pyrigi.graph._constructions.constructions.cone(graph, inplace=False, vertex=None)[source]

Return a coned version of the graph.

Definitions

Cone graph

Parameters:
  • graph (Graph)

  • inplace (bool) – If True, the graph is modified, otherwise a new modified graph is created, while the original graph remains unchanged (default).

  • vertex (Vertex) – It is possible to give the added cone vertex a name using the keyword vertex.

Return type:

Graph

Examples

>>> g = Graph([(0,1)])
>>> G = cone(g)
>>> nx.is_isomorphic(G, Graph([(0,1),(1,2),(0,2)]))
True
pyrigi.graph._constructions.constructions.intersection(graph, other_graph)[source]

Return the intersection with other_graph.

Parameters:
  • graph (Graph)

  • other_graph (Graph)

Return type:

Graph

Examples

>>> H = Graph([[1,2],[2,3],[3,1],[3,4]])
>>> G = Graph([[0,1],[1,2],[2,3],[3,1]])
>>> graph = intersection(G, H)
>>> print(graph)
Graph with vertices [1, 2, 3] and edges [[1, 2], [1, 3], [2, 3]]
>>> G = Graph([[0,1],[0,2],[1,2]])
>>> G.add_node(3)
>>> H = Graph([[0,1],[1,2],[2,4],[4,0]])
>>> H.add_node(3)
>>> graph = intersection(G, H)
>>> print(graph)
Graph with vertices [0, 1, 2, 3] and edges [[0, 1], [1, 2]]
pyrigi.graph._constructions.constructions.sum_t(graph, other_graph, edge, t=2)[source]

Return the t-sum with other_graph along the given edge.

Return type:

Graph

Parameters:
  • graph (Graph)

  • other_graph (Graph)

  • edge (:type:`~pyrigi.data_type.Edge`)

  • t (int)

Definitions

t-sum

Examples

>>> G1 = Graph([[1,2],[2,3],[3,1],[3,4]])
>>> G2 = Graph([[0,1],[1,2],[2,3],[3,1]])
>>> H = sum_t(G2, G1, [1, 2], 3)
>>> print(H)
Graph with vertices [0, 1, 2, 3, 4] and edges [[0, 1], [1, 3], [2, 3], [3, 4]]