No project description provided
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
graph_force-0.1.1.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for graph_force-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1775f587328f113e48a39ba639b7302a51b55d41d4eb08a1c68dcf6a4805ace |
|
MD5 | fbd5d9219d54d470e67df0601d28e32b |
|
BLAKE2b-256 | dfc4a950ee30a241059802ec96ba7032a0c591a6e728b97937ef484d53a99481 |