diff --git a/pyscriptjs/examples/message_passing.html b/pyscriptjs/examples/message_passing.html new file mode 100644 index 0000000..ee10a74 --- /dev/null +++ b/pyscriptjs/examples/message_passing.html @@ -0,0 +1,53 @@ + + +
+ + + + + +Message passing with linear algebra: a demo.
+Imagine we have a chain graph that looks like this:
+O --> 1 --> 2 --> 3
+ In NetworkX this graph would look like the following:
++++G = nx.Graph() +nodes = list(range(4)) +G.add_edges_from(zip(nodes[0:-1], nodes[1:])) +print(G.edges()) +
This chain graph has the following adjacency matrix:
++++adj_mat = np.eye(4, k=1) +print(f"A: {adj_mat}") + +
And imagine that we have a message that lives on the graph:
++++message = np.array([1.0, 0.0, 0.0, 0.0]) +print(f"message: {message}") + +
Try out message passing below by doing any one of the following steps:
+message @ adj_mat
+ message @ adj_mat @ adj_mat
+ message @ adj_mat @ adj_mat @ adj_mat
+