> Every page of the ganymede website is listed in https://eugo.io/docs/ganymede/llms.txt.

# SPAtial GrapHs: nETworks, Topology, & Inference (spaghetti)

> SPAtial GrapHs: nETworks, Topology, & Inference (spaghetti): An open-source Python library for the analysis of network-based spatial data.

Web page: https://eugo.io/docs/ganymede/demo_notebooks/geospatial/pysal/spaghetti/
Notebook: https://eugo.io/docs/ganymede/demo_notebooks/geospatial/pysal/spaghetti/spaghetti.ipynb (source: https://github.com/eugo-inc/ganymede/blob/main/demo_notebooks/geospatial/pysal/spaghetti.ipynb)

Description:
- An open-source Python library for the analysis of network-based spatial data. Originating from the network module in PySAL (Python Spatial Analysis Library), it is under active development for the inclusion of newly proposed methods for building graph-theoretic networks and the analysis of network events.

Resources:
- [GitHub] https://github.com/pysal/spaghetti
- [Examples] https://github.com/pysal/spaghetti/tree/main/notebooks
- [Websites] http://pysal.org/spaghetti/

## Example 1

Get the network component Labels

```python
import geopandas
import libpysal
from libpysal import examples
from libpysal.cg import Point, Chain
import matplotlib
import matplotlib_scalebar
from matplotlib_scalebar.scalebar import ScaleBar
import spaghetti

plus1 = [
    Chain([Point([1, 2]), Point([0, 2])]),
    Chain([Point([1, 2]), Point([1, 1])]),
    Chain([Point([1, 2]), Point([1, 3])]),
]
plus2 = [
    Chain([Point([2, 1]), Point([2, 0])]),
    Chain([Point([2, 1]), Point([3, 1])]),
    Chain([Point([2, 1]), Point([2, 2])]),
]
lines = plus1 + plus2
ntw = spaghetti.Network(in_data=lines)

ntw.network_component_labels
```
