Networkx Graphs synced across devices using Zenoh.
Explore the docs »
Report Bug
·
Request Feature
- run
zenohd -c .zenoh/meshnetworkx.json5
to create a storage - or
docker compose up zenoh-host
to create a storage.
then run the following pip install -e ".[examples]"
to install the package.
Then run an example with python examples/main.py
- If you model your application domain as a graph, this package makes it easy to run on multiple devices and automatically sync the graph between them.
- It is a drop-in replacement for networkx, so you can use all the networkx methods on the graph.
- It is an abstraction on top of the Zenoh protocol, which is a very efficient protocol for IoT applications.
- The graph is stored in a zenoh storage, for more information on how zenoh keeps storages alligned (even if the network becomes partitioned and then later reconnects), check here.
Assuming:
- you have two devices, and you want to create a graph on one device and access it on the other device.
- you have a zenoh storage running on both devices.
- Both devices can find each other using zenoh discovery (local network or using a Zenoh Router).
On device one:
import meshnetworkx as mx
G = mx.Graph()
G.add_node(1, color="red")
G.add_edge(1, 2, color="pink")
After that on device two:
import meshnetworkx as mx
G = mx.Graph()
print(G.nodes(data=True))
>>> [(1, {'color': 'red'}), (2, {})]
print(G.edges(data=True))
>>> [(1, 2, {'color': 'pink'})]