Skip to content

Create a graph

Full example code: examples/graph/graph_creation.py

Graph object

First we create some dummy data on which we will create a graph. A simple cube with scalar weights for each node.

# Coordinates used to create our graph
coords = np.array([
    [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [1.0, 1.0, 0.0],
    [0.0, 1.0, 0.0], [0.0, 1.0, 1.0], [1.0, 1.0, 1.0],
    [1.0, 0.0, 1.0], [0.0, 0.0, 1.0]
])

scalars = np.array([30 * i for i in range(8)]).astype(np.float64)

Creating the graph object

We create a Graph objects by passing our coordinates and scalars to the constructor.

from dgm.graph import Graph

graph = Graph(coords, scalars)

Note that this does not set any edges yet. In our next step we learn how to filter connections to build actual graphs.


← Previous: Graph Overview Next: Filter graph edges →