Skip to content
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
# BellyDynamic [![Build Status](https://travis-ci.org/SamTube405/BellyDynamic.svg?branch=master)](https://travis-ci.org/SamTube405/BellyDynamic)
BellyDynamic: A scalable framework to handle online and offline dynamic graph objects

BellyDynamic: A scalable framework to handle online and offline dynamic graph objects!

## Features:
- [x] Load graphs with node and edge labels (graph annotations)
- [x] An user-defined attribute schema for nodes and edges
- [x] Supports multi-graphs with network annotations
- [x] Represent temporal graphs as labeled graphs with timestamp as an edge attribute
- [x] Handle streaming updates
- [x] Load graphs with node and edge labels (graph annotations).
- [x] An user-defined attribute schema for nodes and edges.
- [x] Supports multi-graphs with network annotations.
- [x] Represent temporal graphs as labeled graphs with timestamp as an edge attribute.
- [x] Handle streaming updates.

## How to run:
- Install [snap] graph mining library (http://snap.stanford.edu/).
- Install [snap] graph mining library: (http://snap.stanford.edu/).
- Test run: https://github.com/scorelab/BellyDynamic/wiki/How-to-Use
Check out the wiki for more information!


## Sponsor:
Google Summer of Code 2017 | SCoRE
Expand Down
20 changes: 10 additions & 10 deletions bellydynamic-metrics/Centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,31 @@ def getOutputFileName(self, suffix):
return self.graphName + suffix + ".txt"

def genGraphInfoBetweeness(self, centrality):
print "\n+++++++++++ %s ++++++++++++" % (centrality)
print "Calculating centrality values..."
print ("\n+++++++++++ %s ++++++++++++" % (centrality))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems you're converting the code to Python 3, better to use the Python3 recommended formatting style with {}.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, but if I may ask, can you clarify what you mean by using a formatting style with { }? Do you mean for me to further format the print statements using { }? Or the code in general? Also, if you are looking to transform all the code in the application into Python 3, may I suggest using "2to3", a Python tool for converting such code?

print ("Calculating centrality values...")
start_time = time.clock()
nodesKeyCentrVals = snap.TIntFltH()
edgesKeyCentrVals = snap.TIntPrFltH()
snap.GetBetweennessCentr(self.G, nodesKeyCentrVals, edgesKeyCentrVals, 1.0)
print "Computation time: %f secs." % (time.clock() - start_time)
print ("Computation time: %f secs." % (time.clock() - start_time))
outputFileName = self.getOutputFileName(centrality)
print "Generating the output -> %s" % (outputFileName)
print ("Generating the output -> %s" % (outputFileName))
output, topNodes = self.getHashmapText(nodesKeyCentrVals)
self.writeOutput(outputFileName, output)
print "Top node labels: \n %s" % (topNodes)
print ("Top node labels: \n %s" % (topNodes))

return nodesKeyCentrVals

def genGraphInfo(self, centrality, func):
print "\n+++++++++++ %s ++++++++++++" % (centrality)
print "Calculating centrality values..."
print ("\n+++++++++++ %s ++++++++++++" % (centrality))
print ("Calculating centrality values...")
start_time = time.clock()
nodesKeysCentrVals = self.getCentr(func)
print "Computation time: %f secs." % (time.clock() - start_time)
print ("Computation time: %f secs." % (time.clock() - start_time))
outputFileName = self.getOutputFileName(centrality)
print "Generating the output -> %s" % (outputFileName)
print ("Generating the output -> %s" % (outputFileName))
output, topNodes = self.getHashmapText(nodesKeysCentrVals)
self.writeOutput(outputFileName, output)
print "Top node labels: \n %s" % (topNodes)
print ("Top node labels: \n %s" % (topNodes))

return nodesKeysCentrVals
16 changes: 8 additions & 8 deletions bellydynamic-metrics/Structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initilize(self, fileName):
self.G = self.getGraph()

def genGraph(self, nodes):
print "Generating random graph..."
print("Generating random graph...")
genFileName = 'random5000by6.txt'
nodesV = snap.TIntV()
for i in range(nodes):
Expand All @@ -38,8 +38,8 @@ def genGraphInfo(self):
graphName = self.graphName

# get the number of nodes and edges in the graph
print "Number of nodes in %s: %d" % (graphName, self.G.GetNodes())
print "Number of edges in %s: %d" % (graphName, self.G.GetEdges())
print("Number of nodes in %s: %d" % (graphName, self.G.GetNodes()))
print("Number of edges in %s: %d" % (graphName, self.G.GetEdges()))

# get the node id(s) with highest degree

Expand All @@ -56,22 +56,22 @@ def genGraphInfo(self):
if (maxDegree == node.GetOutDeg()):
nodeIdsMaxDegreeT += str(node.GetId()) + ","

print "Node id(s) with highest degree in %s: %s" % (graphName, nodeIdsMaxDegreeT)
print ("Node id(s) with highest degree in %s: %s" % (graphName, nodeIdsMaxDegreeT))

# plot degree distribution
snap.PlotOutDegDistr(self.G, graphName, "Degree Distribution")
degreeFileName = "outDeg." + graphName + ".png"
print "Degree distribution of %s is in: %s" % (graphName, degreeFileName)
print ("Degree distribution of %s is in: %s" % (graphName, degreeFileName))

# plot shortest path distribution
snap.PlotShortPathDistr(self.G, graphName, "Shortest Path Distribution")
shortestPathFileName = "diam." + graphName + ".png"
print "Shortest path distribution of %s is in: %s" % (graphName, shortestPathFileName)
print ("Shortest path distribution of %s is in: %s" % (graphName, shortestPathFileName))

# get the fraction of nodes in largest cc
print "Fraction of nodes in largest connected component in %s: %f" % (graphName, snap.GetMxSccSz(self.G))
print ("Fraction of nodes in largest connected component in %s: %f" % (graphName, snap.GetMxSccSz(self.G)))

# plot the component size distribution
snap.PlotSccDistr(self.G, graphName, "Component size distribution")
sccFileName = "scc." + graphName + ".png"
print "Component size distribution of %s is in: %s" % (graphName, sccFileName)
print ("Component size distribution of %s is in: %s" % (graphName, sccFileName))
8 changes: 4 additions & 4 deletions bellydynamic-travis/EdgeAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ def walkGraphEdgeAttributes(self, attribute_type, attribute_name):
EI = self.G.BegEAIntI(attribute_name)
while EI < self.G.EndEAIntI(attribute_name):
if EI.GetDat() != 0:
print "Attribute: %s, Edge: %i, Val: %d" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %d" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()
elif attribute_type == 2:
EI = self.G.BegEAFltI(attribute_name)
while EI < self.G.EndEAFltI(attribute_name):
if EI.GetDat() != 0:
print "Attribute: %s, Edge: %i, Val: %f" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %f" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()
elif attribute_type == 3:
EI = self.G.BegEAStrI(attribute_name)
while EI < self.G.EndEAStrI(attribute_name):
if EI.GetDat() != "NA":
print "Attribute: %s, Edge: %i, Val: %s" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %s" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()

Expand All @@ -55,4 +55,4 @@ def walkEdgeAttributes(self, EId):
AttrLen = EIdAttrValue.Len()

for i in range(AttrLen):
print "Vertical Edge: %i, Attr: %s, Val: %s" % (EId, EIdAttrName.GetI(i)(), EIdAttrValue.GetI(i)())
print ("Vertical Edge: %i, Attr: %s, Val: %s" % (EId, EIdAttrName.GetI(i)(), EIdAttrValue.GetI(i)()))
12 changes: 6 additions & 6 deletions bellydynamic-travis/MultiGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


def PrintGStats(s, Graph):
print "graph %s, nodes %d, edges %d, empty %s" % (
print("graph %s, nodes %d, edges %d, empty %s" % (
s, Graph.GetNodes(), Graph.GetEdges(),
"yes" if Graph.Empty() else "no")
"yes" if Graph.Empty() else "no"))


class MultiGraph:
Expand Down Expand Up @@ -51,19 +51,19 @@ def loadBinaryGraph(self, fileName):
self.G = snap.TNEANet(FIn)

def walkNodes(self):
print "Nodes: "
print("Nodes: ")
NCount = 0
NI = self.G.BegNI()
while NI < self.G.EndNI():
print NI.GetId()
print(NI.GetId())
NCount += 1
NI.Next()

def walkEdges(self):
print "Edges: "
print("Edges: ")
ECount = 0
EI = self.G.BegEI()
while EI < self.G.EndEI():
print EI.GetId()
print(EI.GetId())
ECount += 1
EI.Next()
8 changes: 4 additions & 4 deletions bellydynamic-travis/NodeAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ def walkGraphNodeAttributes(self, attribute_type, attribute_name):
NI = self.G.BegNAIntI(attribute_name)
while NI < self.G.EndNAIntI(attribute_name):
if NI.GetDat() != 0:
print "Attribute: %s, Node: %i, Val: %d" % (attribute_name, NodeId, NI.GetDat())
print ("Attribute: %s, Node: %i, Val: %d" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()
elif attribute_type == 2:
NI = self.G.BegNAFltI(attribute_name)
while NI < self.G.EndNAFltI(attribute_name):
if NI.GetDat() != 0:
print "Attribute: %s, Node: %i, Val: %f" % (attribute_name, NodeId, NI.GetDat())
print ("Attribute: %s, Node: %i, Val: %f" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()
elif attribute_type == 3:
NI = self.G.BegNAStrI(attribute_name)
while NI < self.G.EndNAStrI(attribute_name):
if NI.GetDat() != "NA":
print "Attribute: %s, Node: %i, Val: %s" % (attribute_name, NodeId, NI.GetDat())
print ("Attribute: %s, Node: %i, Val: %s" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()

Expand All @@ -55,4 +55,4 @@ def walkNodeAttributes(self, NId):
AttrLen = NIdAttrValue.Len()

for i in range(AttrLen):
print "Vertical Node: %i, Attr: %s, Val: %s" % (NId, NIdAttrName.GetI(i)(), NIdAttrValue.GetI(i)())
print ("Vertical Node: %i, Attr: %s, Val: %s" % (NId, NIdAttrName.GetI(i)(), NIdAttrValue.GetI(i)()))
8 changes: 4 additions & 4 deletions bellydynamic-util/EdgeAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ def walkGraphEdgeAttributes(self, attribute_type, attribute_name):
EI = self.G.BegEAIntI(attribute_name)
while EI < self.G.EndEAIntI(attribute_name):
if EI.GetDat() != 0:
print "Attribute: %s, Edge: %i, Val: %d" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %d" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()
elif attribute_type == 2:
EI = self.G.BegEAFltI(attribute_name)
while EI < self.G.EndEAFltI(attribute_name):
if EI.GetDat() != 0:
print "Attribute: %s, Edge: %i, Val: %f" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %f" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()
elif attribute_type == 3:
EI = self.G.BegEAStrI(attribute_name)
while EI < self.G.EndEAStrI(attribute_name):
if EI.GetDat() != "NA":
print "Attribute: %s, Edge: %i, Val: %s" % (attribute_name, EdgeId, EI.GetDat())
print("Attribute: %s, Edge: %i, Val: %s" % (attribute_name, EdgeId, EI.GetDat()))
EdgeId += 1
EI.Next()

Expand All @@ -54,4 +54,4 @@ def walkEdgeAttributes(self, EId):
AttrLen = EIdAttrValue.Len()

for i in range(AttrLen):
print "Vertical Edge: %i, Attr: %s, Val: %s" % (EId, EIdAttrName.GetI(i)(),EIdAttrValue.GetI(i)())
print("Vertical Edge: %i, Attr: %s, Val: %s" % (EId, EIdAttrName.GetI(i)(),EIdAttrValue.GetI(i)()))
10 changes: 5 additions & 5 deletions bellydynamic-util/MultiGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def PrintGStats(s, Graph):
print "graph %s, nodes %d, edges %d, empty %s" % (
print("graph %s, nodes %d, edges %d, empty %s" % (
s, Graph.GetNodes(), Graph.GetEdges(),
"yes" if Graph.Empty() else "no")

Expand Down Expand Up @@ -69,20 +69,20 @@ def loadBinaryGraph(self, fileName):
self.G = snap.TNEANet(FIn)

def walkNodes(self):
print "Nodes: "
print("Nodes:)
NCount = 0
NI = self.G.BegNI()
while NI < self.G.EndNI():
print NI.GetId()
print(NI.GetId())
NCount += 1
NI.Next()

def walkEdges(self):
print "Edges: "
print("Edges: ")
ECount = 0
EI = self.G.BegEI()
while EI < self.G.EndEI():
print EI.GetId()
print(EI.GetId())
ECount += 1
EI.Next()

Expand Down
8 changes: 4 additions & 4 deletions bellydynamic-util/NodeAttribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ def walkGraphNodeAttributes(self, attribute_type, attribute_name):
NI = self.G.BegNAIntI(attribute_name)
while NI < self.G.EndNAIntI(attribute_name):
if NI.GetDat() != 0:
print "Attribute: %s, Node: %i, Val: %d" % (attribute_name, NodeId, NI.GetDat())
print("Attribute: %s, Node: %i, Val: %d" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()
elif attribute_type == 2:
NI = self.G.BegNAFltI(attribute_name)
while NI < self.G.EndNAFltI(attribute_name):
if NI.GetDat() != 0:
print "Attribute: %s, Node: %i, Val: %f" % (attribute_name, NodeId, NI.GetDat())
print("Attribute: %s, Node: %i, Val: %f" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()
elif attribute_type == 3:
NI = self.G.BegNAStrI(attribute_name)
while NI < self.G.EndNAStrI(attribute_name):
if NI.GetDat() != "NA":
print "Attribute: %s, Node: %i, Val: %s" % (attribute_name, NodeId, NI.GetDat())
print("Attribute: %s, Node: %i, Val: %s" % (attribute_name, NodeId, NI.GetDat()))
NodeId += 1
NI.Next()

Expand All @@ -54,4 +54,4 @@ def walkNodeAttributes(self, NId):
AttrLen = NIdAttrValue.Len()

for i in range(AttrLen):
print "Vertical Node: %i, Attr: %s, Val: %s" % (NId, NIdAttrName.GetI(i)(),NIdAttrValue.GetI(i)())
print("Vertical Node: %i, Attr: %s, Val: %s" % (NId, NIdAttrName.GetI(i)(),NIdAttrValue.GetI(i)()))
Loading