Simulate graph states in the browser
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

doc.md 2.0KB

il y a 7 ans
il y a 7 ans
il y a 7 ans
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # ABP server
  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":
  21. {"30":
  22. {"position":
  23. {"y": 3.245091885135617, "x": -1.0335390368621762, "z": 0.12485495696298532}, "vop": 0}, "28":
  24. {"position":
  25. {"y": 0.1811335599620998, "x": 3.7102305790943295, "z": 0.3375519427305571}, "vop": 0}, "29":
  26. {"position":
  27. {"y": -1.834182888403804, "x": 1.5968911365745622, "z": 2.8585980299131886
  28. ...
  29. The top-level keys are `node` and `adj`. These model the node metadata and adjacency matrix respectively.
  30. Each `node` has
  31. - a `position` (`{x:<> y:<> z:<>}`)
  32. - a `vop` (integer, ignore for now)
  33. - and could also have a `color`, `label`, etc.
  34. `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.
  35. Here's an example of a graph `(A-B C)`:
  36. :::python
  37. {'adj': {0: {1: {}}, 1: {0: {}}, 2: {}},
  38. 'node': {
  39. 0: {'position': {'x': 0, 'y': 0, 'z': 0}, 'vop': 0},
  40. 1: {'position': {'x': 1, 'y': 0, 'z': 0}, 'vop': 0},
  41. 2: {'position': {'x': 2, 'y': 0, 'z': 0}, 'vop': 10}}}