GithubHelp home page GithubHelp logo

gephistreamer's Introduction

GephiStreamer

Python classes for streaming graph to gephi Install

Download and unzip in your python project in %base%/GephiStreamer/

/!\ Requests module is needed (http://docs.python-requests.org/en/latest/#) /!\

Quick use

from GephiStreamer import Node,Edge,GephiStreamerManager

a = Node("A", red=1) 		# Create a node
a.property['category']= '1'  	# add a property 
b = Node("B",blue=1)		# Create a node
b.property['category']= '2'	# add a property 
e = Edge('A',b,True)		# Create edge, can use Node type or Id of node for Source and Destination
t = GephiStreamerManager()  # Streamer Manager (default http://localhost:8080/workspace0)
t.add_node(a)				
t.add_node(b)
t.add_edge(e)
t.commit()					# Send everything > Group streaming by action (e.g if you have 1000 nodes to add, it will send only one message to gephi)
""" Or Alternative
t.send(GephiStreamerManager.ADD_NODE,a)					# send a to gephi
t.send(GephiStreamerManager.ADD_NODE,b)					# send b to gephi
t.send(GephiStreamerManager.ADD_EDGE,e)					# send e to gephi

"""

Direct Send Mode

Direct Send Mode use the GephiStreamerManager.send method to send one action immediatly.

from GephiStreamer import Node,Edge,GephiStreamerManager
t = GephiStreamerManager()  # Streamer Manager (default http://localhost:8080/workspace0)

a = Node("A", red=1)   
t.send(GephiStreamerManager.ADD_NODE,a)  				
b = Node("B",blue=1)		
e = Edge('A',b,True)		


t.send(GephiStreamerManager.ADD_NODE,b)    			# send b to gephi
t.send(GephiStreamerManager.ADD_EDGE,e)    			# send e to gephi

This mode is usefull for quick implementation.

Transaction Mode

The transaction mode store all the action to perform and will send only at commit GephiStreamerManager.call

from GephiStreamer import Node,Edge,GephiStreamerManager
t = GephiStreamerManager()  # Streamer Manager (default http://localhost:8080/workspace0)

a = Node("A", red=1)   	# Create a node
b = Node("B",blue=1)		# Create a node
e = Edge('A',b,True)	

t.add_node(a)				
t.add_node(b)
t.add_edge(e)
t.commit()				

The advantage to use this mode is that it will pack all same actions into one gephi call, whereas the Driect Send Mode do one call per entity. It's should be faster for creating large set of entities in "one shot"

Example: I want to create 1 node that have a edge to 10 000 other nodes

  • Direct Send Mode : will operate 20 001 calls (10 001 calls for nodes, 10 000 for edges)
  • Transaction Mode : will operate 2 calls (1 for add 10 001 nodes, 1 for add 10 000 edges)

Gephi Instance

Default Gephi instance targeted is localhost on port 8080

t = GephiStreamerManager()

To stream a remote Gephi instance use the argument iGephiUrl

t = GephiStreamerManager(iGephiUrl='ip_or_machine_name:myport')

To stream to a different workspace, usr the argument iGephiWorkspace

t = GephiStreamerManager(iGephiWorkspace='workspace1')

gephistreamer's People

Contributors

totetmatt avatar

Watchers

 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.