Skip to content

network_plots

Network plots with d3js.

NetworkPlot

Bases: pathpyG.visualisations._d3js.core.D3jsPlot

Network plot class for a static network.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
class NetworkPlot(D3jsPlot):
    """Network plot class for a static network."""

    _kind = "network"

    def __init__(self, data: dict, **kwargs: Any) -> None:
        """Initialize network plot class."""
        super().__init__()
        self.data = data
        self.config = kwargs
        self.generate()

    def generate(self) -> None:
        """Clen up data."""
        self.config.pop("node_cmap", None)
        self.config.pop("edge_cmap", None)
        for node in self.data["nodes"]:
            node.pop("x", None)
            node.pop("y", None)

    def to_json(self) -> Any:
        """Convert data to json."""
        return json.dumps(self.data)

__init__

Initialize network plot class.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
def __init__(self, data: dict, **kwargs: Any) -> None:
    """Initialize network plot class."""
    super().__init__()
    self.data = data
    self.config = kwargs
    self.generate()

generate

Clen up data.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
def generate(self) -> None:
    """Clen up data."""
    self.config.pop("node_cmap", None)
    self.config.pop("edge_cmap", None)
    for node in self.data["nodes"]:
        node.pop("x", None)
        node.pop("y", None)

to_json

Convert data to json.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
def to_json(self) -> Any:
    """Convert data to json."""
    return json.dumps(self.data)

StaticNetworkPlot

Bases: pathpyG.visualisations._d3js.network_plots.NetworkPlot

Network plot class for a temporal network.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
class StaticNetworkPlot(NetworkPlot):
    """Network plot class for a temporal network."""

    _kind = "static"

TemporalNetworkPlot

Bases: pathpyG.visualisations._d3js.network_plots.NetworkPlot

Network plot class for a temporal network.

Source code in src/pathpyG/visualisations/_d3js/network_plots.py
class TemporalNetworkPlot(NetworkPlot):
    """Network plot class for a temporal network."""

    _kind = "temporal"