Go to file
Niko Abeler a503ba80ed networkx spring_layout copy 2022-11-22 22:26:09 +01:00
.vscode formatting 2022-11-20 17:09:39 +01:00
src networkx spring_layout copy 2022-11-22 22:26:09 +01:00
tests more tests + allowing generators as input 2022-11-20 21:44:24 +01:00
.gitignore more tests + allowing generators as input 2022-11-20 21:44:24 +01:00
Cargo.lock version bump 2022-11-20 21:45:18 +01:00
Cargo.toml version bump 2022-11-20 21:45:18 +01:00
DEVELOPMENT.md install and dev 2022-11-20 19:03:45 +01:00
README.md install and dev 2022-11-20 19:03:45 +01:00
pyproject.toml pyproject filled 2022-11-22 22:25:49 +01:00
requirements.txt more tests + allowing generators as input 2022-11-20 21:44:24 +01:00

README.md

Graph Force

A python/rust library for embedding graphs in 2D space, using force-directed layouts.

Installation

pip install graph_force

Usage

import graph_force

edges = [(0, 1), (1, 2), (2, 3), (3, 0)]
pos = graph_force.layout_from_edge_list(4, edges)

Example with networkx

import networkx as nx
import graph_force

G = nx.grid_2d_graph(10, 10)
# we have to map the names to integers
# as graph_force only supports integers as node ids at the moment
edges = []
mapping = {n: i for i, n in enumerate(G.nodes)}
i = 0
for edge in G.edges:
    edges.append((mapping[edge[0]], mapping[edge[1]]))

pos = graph_force.layout_from_edge_list(len(G.nodes), edges, iter=1000)
nx.draw(G, {n: pos[i] for n, i in mapping.items()}, node_size=2, width=0.1)

Contributing