GithubHelp home page GithubHelp logo

xianyuzhang0709 / force-directed-layout-algorithms Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iain530/force-directed-layout-algorithms

0.0 0.0 0.0 16.88 MB

Force directed layout algorithms for Python

Python 100.00%

force-directed-layout-algorithms's Introduction

Force Directed Layout Algorithms for Python

Setup

Before this package can be used, dependencies must be installed.

python3 -m pip install forcelayout

or

python3 -m pip install -r requirements.txt

Locations of the three main algorithms of this project:

Usage

Documentation on full usage of the forcelayout package is available in the forcelayout/README.md

Examples

Examples are contained in the examples/ folder. Three command line scripts are included and a jupyter notebook.

examples/poker_hands_layout.py

This script will create a static layout of the poker hands dataset rendering using matplotlib. This shows the colouring functionality and annotations for each node when hovered. Nodes can be clicked to highlight other nodes based on the algorithm:

  • Chalmers' 1996: Highlight the nodes in the neighbour set for the selected node.
  • Hybrid: Highlight the nodes in the sample layout
  • Pivot: Highlight the pivot nodes

The size of dataset can be changed to any available size in datasets/poker/ and the algorithms available are: brute, chalmers96, hybrid and pivot.

Run it using the following commands:

cd examples/
# python3 poker_hands_layout.py [size] [brute | chalmers96 | hybrid | pivot]
python3 poker_hands_layout.py 500 pivot
examples/animated_poker_hands_layout.py

This is similar to the above example but will show an animated version of the layout.

cd examples/
# python3 poker_hands_layout.py [size] [brute | chalmers96 | hybrid | pivot]
python3 animated_poker_hands_layout.py 500 pivot
examples/iris_layout.py

This will show an animated layout of the iris dataset using Chalmers' 1996 algorithm, also an image will be saved of the final layout.

cd examples/
python3 iris_layout.py
examples/notebook_poker_layouts.ipynb

This is an example notebook creating layouts of the poker hands dataset. Jupyter notebook is required to run this which can be installed here.

Testing

In order to run tests, pytest is required:

python3 -m pip install pytest

To run the test cases run the following command from the root directory:

python3 -m pytest forcelayout/ tests/forcelayout

Note that the test cases are written and run on Ubuntu 18.04 with Python 3.6.7 with Pytest 4.0.2.

Datasets

I do not own the datasets in this repository, they can be accessed from their source at:

force-directed-layout-algorithms's People

Contributors

iain530 avatar xianyuzhang0709 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.