Graph Module

Module that defines the abstract Graph class and different classes of Graphs that inherit from it

class polyhex.objects.graphs.graphs_module.EdgeBorderGraph(name='EdgeBorderGraph')

Bases: Graph

Graph of polyhex edges border

add(hexagon: Hexagon, edge: HexagonEdge)

Internal helper function to clarify the append code

Parameters:
  • hexagon (Hexagon) – Hexagon to append to the border

  • edge (HexagonEdge) – Edge considered

append(hexagon: Hexagon)

Append method of the EdgeBorderGraph. The border of a polyhex can be defined by its Edges of by its Hexagons. For Polyhex with varying edge features, it is important to know what edges are on the border

Parameters:

hexagon (Hexagon) – Hexagon to append to the graph.

remove(hexagon: Hexagon, edge: HexagonEdge)

Internal helper function to clarify the append code

Parameters:
  • hexagon (Hexagon) – Hexagon to append to the border

  • edge (HexagonEdge) – Edge considered

class polyhex.objects.graphs.graphs_module.EdgeGraph(name='EdgeGraph')

Bases: Graph

Graph of polyhex edges

append(hexagon: Hexagon)

Append method of the EdgeGraph

Parameters:

hexagon (Hexagon) – Hexagon of which edges to append to the graph

class polyhex.objects.graphs.graphs_module.Graph(name: str)

Bases: ABC

Abstract Graph class

__init__(name: str)

Constructor for a graph

Parameters:

name (str) – name of the graph

By default, a graph has:

name (str) : name of the Graph n_nodes (int) : number of nodes nodes (dict) : dictionnary with spatial coordinates as keys and objects (Hexagon, Edge…) as values. It refers to the nodes of the graph. weights (dict) : dictionnary with spatial coordinates as keys and a list of objects (Hexagon, Edge…) as values. It refers to the connexions between the nodes of the graph nodes (dict) : the dictionnary with spatial coordinates as keys and integers as values. It refers to the indexing of each node in the graph

abstractmethod append()

Append method for the Graph

class polyhex.objects.graphs.graphs_module.HexagonBorderGraph(name='HexagonBorderGraph')

Bases: Graph

Graph of polyhex hexagons border

add(polyhex: Polyhex, adj: Tuple[int], hexagon_graph: HexagonGraph)

Helper function for clarifying the append method of the HexagonBorderGraph class.

Parameters:
  • polyhex (Polyhex) – the polyhex considered. The border cannot be defined without the polyhex as it creates placeholder nodes.

  • adj (Tuple[int]) – One of the adjency coordinate of the considered hexagon

  • hexagon_graph (HexagonGraph) – the hexagon graph representing the polyhex. The border cannot be defined without the HexagonGraph.

append(hexagon: Hexagon, hexagon_graph: HexagonGraph, polyhex: Polyhex)

Append method of the EdgeBorderGraph. The border of a polyhex can be defined by its Edges of by its Hexagons. When considering the Hexagon border, it is important to consider the following:

  1. the hexagon border is defined only against a hexagon graph

  2. the hexagon border is made of placeholder hexagons, that look like the ones the polyhex would expect. This is why a polyhex object is required.

Parameters:
  • hexagon (Hexagon) – The hexagon to append to the border.

  • hexagon_graph (HexagonGraph) – The hexagon graph to build the border against.

  • polyhex (Polyhex) – The polyhex considered

class polyhex.objects.graphs.graphs_module.HexagonGraph(name='HexagonGraph')

Bases: Graph

Graph of polyhex hexagons

append(hexagon: Hexagon)

Append method of the HexagonGraph

Parameters:

hexagon (Hexagon) – Hexagon to append to the graph

class polyhex.objects.graphs.graphs_module.VertexGraph(name='VertexGraph')

Bases: Graph

Graph of polyhex vertices

append(hexagon: Hexagon)

Append method of the VertexGraph

Parameters:

hexagon (Hexagon) – Hexagon of which vertices to append to the graph