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:
GraphGraph 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 borderedge (
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 borderedge (
HexagonEdge) – Edge considered
- class polyhex.objects.graphs.graphs_module.EdgeGraph(name='EdgeGraph')
Bases:
GraphGraph of polyhex edges
- class polyhex.objects.graphs.graphs_module.Graph(name: str)
Bases:
ABCAbstract 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
- sample(random_generator)
- class polyhex.objects.graphs.graphs_module.HexagonBorderGraph(name='HexagonBorderGraph')
Bases:
GraphGraph 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 hexagonhexagon_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:
the hexagon border is defined only against a hexagon graph
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