Simulate graph states in the browser
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

doc.md 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # ABP
  2. This server does a few things:
  3. - Keeps a graph state in memory using a data structure that is compatible with `abp`
  4. - Serves a JSON representation of that object
  5. - Accepts updates to that object via POST requests
  6. - Displays a 3D representation of the state
  7. - Randomly updates the state every five seconds
  8. ## Endpoints
  9. - `/`: Displays the state using Three.js
  10. - `graph/`:
  11. - `GET` returns JSON representing the state
  12. - `POST` accepts JSON in the same format and overwrites the state in memory
  13. - `doc/`: Shows this page
  14. ## Data format
  15. If you do an HTTPS GET against `graph/`, you will receive some JSON.
  16. :::bash
  17. $ curl https://abv.peteshadbolt.co.uk/graph
  18. outputs
  19. :::python
  20. {"node": {"30": {"position": {"y": 3.245091885135617, "x": -1.0335390368621762, "z": 0.12485495696298532}, "vop": 0}, "28": {"position": {"y": 0.1811335599620998, "x": 3.7102305790943295, "z": 0.3375519427305571}, "vop": 0}, "29": {"position": {"y": -1.834182888403804, "x": 1.5968911365745622, "z": 2.8585980299131886 ...
  21. The top-level keys are `node` and `adj`. These model the node metadata and adjacency matrix respectively.
  22. Each `node` has
  23. - a `position` (`{x:<> y:<> z:<>}`)
  24. - a `vop` (integer, ignore for now)
  25. - and could also have a `color`, `label`, etc.
  26. `adj` uses the same data structure as `networkx` to efficiently represent sparse adjacency matrices. For each key `i` in `adj`, the value of `adj[i]` is itself a map whose keys `j` correspond to the ids of nodes connected to `i`. The value of `adj[i][j]` is a map which is usually empty but which could be used to store metadata about the edge.
  27. Here's an example of a graph `(A-B C)`:
  28. :::python
  29. {'adj': {0: {1: {}}, 1: {0: {}}, 2: {}},
  30. 'node': {
  31. 0: {'position': {'x': 0, 'y': 0, 'z': 0}, 'vop': 0},
  32. 1: {'position': {'x': 1, 'y': 0, 'z': 0}, 'vop': 0},
  33. 2: {'position': {'x': 2, 'y': 0, 'z': 0}, 'vop': 10}}}