All Projects → bhargavchippada → Forceatlas2

bhargavchippada / Forceatlas2

Licence: gpl-3.0
Fastest Gephi's ForceAtlas2 graph layout algorithm implemented for Python and NetworkX

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Forceatlas2

Codeatlasvsix
A graph-based code navigation plugin for Visual Studio
Stars: ✭ 133 (-13.64%)
Mutual labels:  graph
Sparkling Graph
SparklingGraph provides easy to use set of features that will give you ability to proces large scala graphs using Spark and GraphX.
Stars: ✭ 139 (-9.74%)
Mutual labels:  graph
Neo4j Php Ogm
Neo4j Object Graph Mapper for PHP
Stars: ✭ 151 (-1.95%)
Mutual labels:  graph
Blockchain2graph
Blockchain2graph extracts blockchain data (bitcoin) and insert them into a graph database (neo4j).
Stars: ✭ 134 (-12.99%)
Mutual labels:  graph
Urbanaccess
A tool for GTFS transit and OSM pedestrian network accessibility analysis
Stars: ✭ 137 (-11.04%)
Mutual labels:  graph
Graphembeddingrecommendationsystem
Python based Graph Propagation algorithm, DeepWalk to evaluate and compare preference propagation algorithms in heterogeneous information networks from user item relation ship.
Stars: ✭ 144 (-6.49%)
Mutual labels:  graph
Reddit Detective
Play detective on Reddit: Discover political disinformation campaigns, secret influencers and more
Stars: ✭ 129 (-16.23%)
Mutual labels:  graph
Backprop
Heterogeneous automatic differentiation ("backpropagation") in Haskell
Stars: ✭ 154 (+0%)
Mutual labels:  graph
Data Structures
Common data structures and algorithms implemented in JavaScript
Stars: ✭ 139 (-9.74%)
Mutual labels:  graph
Graphlib
Simple but powerful graph library for Rust
Stars: ✭ 148 (-3.9%)
Mutual labels:  graph
Sonic
🦔 Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.
Stars: ✭ 12,347 (+7917.53%)
Mutual labels:  graph
Question Pairs Matching
第三届魔镜杯 智能客服问题相似性算法设计 第12名解决方案
Stars: ✭ 138 (-10.39%)
Mutual labels:  graph
Aachartkit Swift
📈📊📱💻🖥️An elegant modern declarative data visualization chart framework for iOS, iPadOS and macOS. Extremely powerful, supports line, spline, area, areaspline, column, bar, pie, scatter, angular gauges, arearange, areasplinerange, columnrange, bubble, box plot, error bars, funnel, waterfall and polar chart types. 极其精美而又强大的跨平台数据可视化图表框架,支持柱状图、条形图、…
Stars: ✭ 1,962 (+1174.03%)
Mutual labels:  graph
Goimportdot
A tiny tool to draw a graph of golang package import relationship
Stars: ✭ 134 (-12.99%)
Mutual labels:  graph
Graphview
Flutter GraphView is used to display data in graph structures. It can display Tree layout, Directed and Layered graph. Useful for Family Tree, Hierarchy View.
Stars: ✭ 152 (-1.3%)
Mutual labels:  graph
Lds Gnn
Learning Discrete Structures for Graph Neural Networks (TensorFlow implementation)
Stars: ✭ 131 (-14.94%)
Mutual labels:  graph
Setreplace
Wolfram Language Package for exploring Set and Hypergraph Substitution Systems
Stars: ✭ 142 (-7.79%)
Mutual labels:  graph
Graphembedding
Implementation and experiments of graph embedding algorithms.
Stars: ✭ 2,461 (+1498.05%)
Mutual labels:  graph
Graspologic
Python package for graph statistics
Stars: ✭ 153 (-0.65%)
Mutual labels:  graph
Lagmonitor
Monitor performance of your Minecraft server. Similar to VisualVM and Java Mission Control.
Stars: ✭ 147 (-4.55%)
Mutual labels:  graph

ForceAtlas2 for Python

A port of Gephi's Force Atlas 2 layout algorithm to Python 2 and Python 3 (with a wrapper for NetworkX and igraph). This is the fastest python implementation available with most of the features complete. It also supports Barnes Hut approximation for maximum speedup.

ForceAtlas2 is a very fast layout algorithm for force-directed graphs. It's used to spatialize a weighted undirected graph in 2D (Edge weight defines the strength of the connection). The implementation is based on this paper and the corresponding gephi-java-code. Its really quick compared to the fruchterman reingold algorithm (spring layout) of networkx and scales well to high number of nodes (>10000).

Spatialize a random Geometric Graph

Geometric Graph

Installation

Install from pip:

pip install fa2

To build and install run from source:

python setup.py install

Cython is highly recommended if you are buidling from source as it will speed up by a factor of 10-100x depending on the graph

Dependencies

  • numpy (adjacency matrix as complete matrix)
  • scipy (adjacency matrix as sparse matrix)
  • tqdm (progressbar)
  • Cython (10-100x speedup)
  • networkx (To use the NetworkX wrapper function, you obviously need NetworkX)
  • python-igraph (To use the igraph wrapper)

Spatialize a 2D Grid

Grid Graph

Usage

from fa2 import ForceAtlas2

Create a ForceAtlas2 object with the appropriate settings. ForceAtlas2 class contains three important methods:

forceatlas2 (G, pos, iterations)
# G is a graph in 2D numpy ndarray format (or) scipy sparse matrix format. You can set the edge weights (> 0) in the matrix
# pos is a numpy array (Nx2) of initial positions of nodes
# iterations is num of iterations to run the algorithm
# returns a list of (x,y) pairs for each node's final position
forceatlas2_networkx_layout(G, pos, iterations)
# G is a networkx graph. Edge weights can be set (if required) in the Networkx graph
# pos is a dictionary, as in networkx
# iterations is num of iterations to run the algorithm
# returns a dictionary of node positions (2D X-Y tuples) indexed by the node name
forceatlas2_igraph_layout(G, pos, iterations, weight_attr)
# G is an igraph graph
# pos is a numpy array (Nx2) or list of initial positions of nodes (see that the indexing matches igraph node index)
# iterations is num of iterations to run the algorithm
# weight_attr denotes the weight attribute's name in G.es, None by default
# returns an igraph layout

Below is an example usage. You can also see the feature settings of ForceAtlas2 class.

import networkx as nx
from fa2 import ForceAtlas2
import matplotlib.pyplot as plt

G = nx.random_geometric_graph(400, 0.2)

forceatlas2 = ForceAtlas2(
                        # Behavior alternatives
                        outboundAttractionDistribution=True,  # Dissuade hubs
                        linLogMode=False,  # NOT IMPLEMENTED
                        adjustSizes=False,  # Prevent overlap (NOT IMPLEMENTED)
                        edgeWeightInfluence=1.0,

                        # Performance
                        jitterTolerance=1.0,  # Tolerance
                        barnesHutOptimize=True,
                        barnesHutTheta=1.2,
                        multiThreaded=False,  # NOT IMPLEMENTED

                        # Tuning
                        scalingRatio=2.0,
                        strongGravityMode=False,
                        gravity=1.0,

                        # Log
                        verbose=True)

positions = forceatlas2.forceatlas2_networkx_layout(G, pos=None, iterations=2000)
nx.draw_networkx_nodes(G, positions, node_size=20, with_labels=False, node_color="blue", alpha=0.4)
nx.draw_networkx_edges(G, positions, edge_color="green", alpha=0.05)
plt.axis('off')
plt.show()

# equivalently
import igraph
G = igraph.Graph.TupleList(G.edges(), directed=False)
layout = forceatlas2.forceatlas2_igraph_layout(G, pos=None, iterations=2000)
igraph.plot(G, layout).show()

You can also take a look at forceatlas2.py file for understanding the ForceAtlas2 class and its functions better.

Features Completed

  • barnesHutOptimize: Barnes Hut optimization, n2 complexity to n.ln(n)
  • gravity: Attracts nodes to the center. Prevents islands from drifting away
  • Dissuade Hubs: Distributes attraction along outbound edges. Hubs attract less and thus are pushed to the borders
  • scalingRatio: How much repulsion you want. More makes a more sparse graph
  • strongGravityMode: A stronger gravity view
  • jitterTolerance: How much swinging you allow. Above 1 discouraged. Lower gives less speed and more precision
  • verbose: Shows a progressbar of iterations completed. Also, shows time taken for different force computations
  • edgeWeightInfluence: How much influence you give to the edges weight. 0 is "no influence" and 1 is "normal"

Documentation

You will find all the documentation in the source code

Contributors

Contributions are highly welcome. Please submit your pull requests and become a collaborator.

Copyright

Copyright (C) 2017 Bhargav Chippada [email protected]
Licensed under the GNU GPLv3.

The files are heavily based on the java files included in Gephi, git revision 2b9a7c8 and Max Shinn's port to python of the algorithm. Here I include the copyright information from those files:

Copyright 2008-2011 Gephi
Authors : Mathieu Jacomy <[email protected]>
Website : http://www.gephi.org
Copyright 2011 Gephi Consortium. All rights reserved.
Portions Copyrighted 2011 Gephi Consortium.
The contents of this file are subject to the terms of either the
GNU General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with
the License.

<https://github.com/mwshinn/forceatlas2-python>
Copyright 2016 Max Shinn <[email protected]>
Available under the GPLv3

Also, thanks to Eugene Bosiakov <https://github.com/bosiakov/fa2l>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].