GraphEdges

A list of edges in a graph.

By default, edges are undirected.

Components components

Required: GraphEdge

Recommended: GraphType

Shown in shown-in

Examples examples

Simple undirected graph simple-undirected-graph

"""Log a simple undirected graph."""

import rerun as rr

rr.init("rerun_example_graph_undirected", spawn=True)

rr.log(
    "simple",
    rr.GraphNodes(
        node_ids=["a", "b", "c"], positions=[(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)], labels=["A", "B", "C"]
    ),
    rr.GraphEdges(
        edges=[("a", "b"), ("b", "c"), ("c", "a")],
        # Optional: graphs are undirected by default.
        graph_type="undirected",
    ),
)

Simple directed graph simple-directed-graph

"""Log a simple directed graph."""

import rerun as rr

rr.init("rerun_example_graph_directed", spawn=True)

rr.log(
    "simple",
    rr.GraphNodes(
        node_ids=["a", "b", "c"], positions=[(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)], labels=["A", "B", "C"]
    ),
    rr.GraphEdges(edges=[("a", "b"), ("b", "c"), ("c", "a")], graph_type="directed"),
)