import conedy as co N = co.network() N.cycle(99, 1, co.node(), co.weightedEdge(0.25)) print "Should be 100: %f" % N.meanPathLength()
import conedy as co net = co.network() net.addNode (co.node()) net.addEdge (0,0,co.weightedEdge(1.0)) net.removeEdges(co.weightedEdge()) print "Should be 0:" + str(net.meanDegree()) net.clear() net.cycle (10000, 2, co.node(), co.staticWeightedEdge()) net.rewire (0.5, co.weightedEdge(1.0)) print "Should be 4:" + str(net.meanDegree()) net.removeEdges (co.weightedEdge(1.0)) print "Should be close to 2:" + str(net.meanDegree())
import conedy as co N = co.network() N.addNode(co.node()) N.addNode(co.node()) N.addWeightedEdge(0, 1, 0.7) print "Should be 0.7:" + N.linkStrength(0, 1)
import conedy as co N = co.network() N.lattice(40, 40, 1.5, co.node(),co.weightedEdge()) print "should be 1600: " + str(N.size()) N.clear() N.cycle(50, 3, co.node(), co.weightedEdge() ) print "should be 50: " + str(N.size())
import conedy as co N = co.network() N.line( 1000, 1, co.node(), co.weightedEdge(1.0) ) # Creates a closed chain of 100 nodes where each is connected to its 10 nearest neighbors to each side. print "should be 1000:" + str(N.numberVertices()) print "should be 1.0:" + str(N.meanWeight()) print "should be 0.0:" + str(N.meanClustering()) print "should be 333:" + str(N.meanPathLength()) print "should be close to 2:" + str(N.meanDegree())
import conedy as co N = co.network(); N.cycle (100,10, co.node(), co.weightedEdge()); print "should be 20:"+ str(N.meanDegree()) N.saveAdjacencyList("output/rewireWeights.co.before"); N.rewireWeights(0.5, co.uniform (2.0,2.0)); N.saveAdjacencyList("output/rewireWeights.co.after"); print "should be close to 1.5:"+ str(N.meanWeight())
import conedy as co N = co.network() i = N.cycle(20, 1, co.node(), co.weightedEdge()) N.addEdge(i + 1, i + 7, co.weightedEdge(1.0)) N.addEdge(i + 7, i + 1, co.weightedEdge(2.0)) N.addEdge(i + 1, i + 11, co.weightedEdge(3.0)) N.addEdge(i + 11, i + 1, co.weightedEdge(4.0)) N.closenessCentrality("output/closenessCentrality.py.out")
import conedy as co N = co.network() N.addNode (co.node()) N.addNode (co.roessler()) N.removeNodes(co.node()) print "Should be 1:" + str(N.numberVertices())
import conedy as co N = co.network() N.torusNearestNeighbors( 40, 40, 36.0, co.node(), co.weightedEdge() ) #creates a torus of nodes, where each is connected to its 8 (4 direct, 4 diagonal) nearest neighbors and to 2 neighbors with distance 2 randomly chosen print "should be 36.0:" + str(N.meanDegree())
import conedy as co N = co.network() source = N.addNode(co.node()) target = N.addNode(co.node()) N.addEdge (source, target, co.weightedEdge(1.0)) print "Should be True: " + str(N.isLinked (source,target)) print "Should be Talse: " + str(N.isLinked (target,source))
import conedy as co n = co.network() n.addNode(co.node()) n.removeNodes(co.roessler()) print "Should be 1:" + str(n.numberVertices()) n.replaceNode(0, co.roessler()) n.removeNodes(co.roessler()) print "Should be 0:" + str(n.numberVertices())
import conedy as co N = co.network() #N.completeNetwork (10, co.node(), co.weightedEdge()); N.completeNetwork(10) N.saveAdjacencyList("output/createFromAdjacencyList.py.mat") N.clear() N.createFromAdjacencyList("output/createFromAdjacencyList.py.mat", co.node(), co.weightedEdge() ) N.saveAdjacencyList("output/createFromAdjacencyList.py.mat2")
import conedy as co N = co.network() #N.completeNetwork (10, co.node(), co.weightedEdge()); N.completeNetwork(10) N.saveAdjacencyList("output/createFromAdjacencyList.py.mat") N.clear() N.createFromAdjacencyList("output/createFromAdjacencyList.py.mat", co.node(), co.weightedEdge()) N.saveAdjacencyList("output/createFromAdjacencyList.py.mat2")
import conedy as co N = co.network() N.cycle(100,4) print "Should be close to %f: %f" % (9./14, N.meanClustering()) N.clear() N.torus (40, 40, 1.5, co.node(), co.weightedEdge(1.0)) print "Should be close to %f: %f" % (6./14, N.meanClustering())
import conedy as co N = co.undirectedNetwork() N.cycle(100, 4, co.node(), co.weightedEdge(0.1)) N.rewire(0.3) print "Initial mean degree:" + str(N.meanDegree()) N.removeRandomEdges(0.5, co.weightedEdge(0.1)) print "Should have changed:" + str(N.meanDegree())
import conedy as co N = co.network() N.cycle(100, 4) print "Should be close to %f: %f" % (9. / 14, N.meanClustering()) N.clear() N.torus(40, 40, 1.5, co.node(), co.weightedEdge(1.0)) print "Should be close to %f: %f" % (6. / 14, N.meanClustering())
import conedy as co N = co.network() N.cycle(100, 1, co.node(), co.weightedEdge()) N.randomizeWeights(co.uniform(0.0, 1.50)) print "should be close to 0.75:" + str(N.meanWeight())
import conedy as co N = co.network() N.completeNetwork( 10 ) # creates a network of 10 nodes, where every pair is connected by an unweighted edge print "Should be 9: " + str(N.meanDegree()) N.clear() N.cycle(50, 3, co.node(), co.weightedEdge()) N.rewire(0.9) print "Should be 6: " + str(N.meanDegree())
import conedy as co net = co.network() net.addNode(co.node()) net.addEdge(0, 0, co.weightedEdge(1.0)) net.removeEdges(co.weightedEdge()) print "Should be 0:" + str(net.meanDegree()) net.clear() net.cycle(10000, 2, co.node(), co.staticWeightedEdge()) net.rewire(0.5, co.weightedEdge(1.0)) print "Should be 4:" + str(net.meanDegree()) net.removeEdges(co.weightedEdge(1.0)) print "Should be close to 2:" + str(net.meanDegree())
import conedy as co N = co.network() N.completeNetwork(10) # creates a network of 10 nodes, where every pair is connected by an unweighted edge print "Should be 9: " + str (N.meanDegree()) N.clear() N.cycle(50, 3, co.node(), co.weightedEdge()) N.rewire(0.9) print "Should be 6: " + str (N.meanDegree())
import conedy as co co.setRandomSeed(0) N = co.network() N.cycle(1000,50, co.node(), co.weightedEdge()) # Creates a closed chain of 1000 nodes where each is connected to its 50 nearest neighbors to each side. print "should be close to 0.75:" + str ( N.meanClustering() ) print "should be close to " + str (1000.0/ 2 / 100) +":" + str ( N.meanPathLength() ) print "should be 100:" + str ( N.meanDegree() )
import conedy as co N = co.network() N.randomNetwork (10, 0.2, co.node(), co.weightedEdge()); N.saveAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat") N.clear() N.createFromAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat") N.saveAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat2")
import conedy as co N = co.network() N.randomNetwork(10, 0.2, co.node(), co.weightedEdge()) N.saveAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat") N.clear() N.createFromAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat") N.saveAdjacencyMatrix("output/saveAdjacencyMatrix.py.mat2")
import conedy as co N = co.network() N.cycle( 100, 10,co.node(), co.staticWeightedEdge()) #N.printNodeStatistics(); print "should be 20:"+ str(N.meanDegree()) N.rewireUndirected(1.0) print "should be 20:"+ str(N.meanDegree()) N.saveAdjacencyList("output/rewireUndirected.py.graph") if (N.isDirected()): print "Error: The network is directed."
import conedy as co N = co.directedNetwork() N.randomNetwork(100, 0.2, co.node(), co.weightedEdge(1.0)) print "should be close to 20:" + str( N.meanDegree() ) print "should be close to 0.2:" + str( N.meanClustering() ) print "should be directed:" + str (N.isDirected()) UN = co.undirectedNetwork() UN.randomNetwork(100, 0.2, co.node(), co.weightedEdge(1.0)) print "should be close to 20:" + str( UN.meanDegree() ) print "should be close to 0.2:" + str( UN.meanClustering() ) print "should be undirected:" + str (UN.isDirected())
import conedy as co N = co.network() N.line(1000,1, co.node(), co.weightedEdge(1.0)) # Creates a closed chain of 100 nodes where each is connected to its 10 nearest neighbors to each side. print "should be 1000:" + str ( N.size() ) print "should be 1.0:" + str ( N.meanWeight() ) print "should be 0.0:" + str ( N.meanClustering() ) print "should be 333:" + str ( N.meanPathLength() ) print "should be close to 2:" + str ( N.meanDegree() )
import conedy as co N = co.network() source = N.addNode(co.node()) target = N.addNode(co.node()) N.addEdge(source, target, co.weightedEdge(1.0)) print "Should be True: " + str(N.isLinked(source, target)) print "Should be Talse: " + str(N.isLinked(target, source))
import conedy as co N = co.network() N.torusNearestNeighbors (40,40,36.0, co.node(), co.weightedEdge()) #creates a torus of nodes, where each is connected to its 8 (4 direct, 4 diagonal) nearest neighbors and to 2 neighbors with distance 2 randomly chosen print "should be 36.0:" + str(N.meanDegree())
import conedy as co N = co.network() N.lattice (40,40,1.5, co.node(), co.weightedEdge()) #creates a lattice of nodes, where each is connected to its 8 (4 direct, 4 diagonal) nearest neighbors print "should be slightly smaller than 8:" + str(N.meanDegree()) print "should be close to "+ str(12.0/28) +":" + str(N.meanClustering())
import conedy as co N = co.network() N.addNode(co.node()) N.addNode() N.addEdge(0, 1, co.weightedEdge(0.3)) N.addEdge(1, 0, co.staticWeightedEdge(0.2)) N.printNodeStatistics() uN = co.undirectedNetwork() sourceNode = uN.addNode(co.node()) targetNode = uN.addNode() #addEdge connects nodes in undirected networks also in the opposite direction. uN.addEdge(sourceNode, targetNode, co.weightedEdge(1.0)) print "linkStrength (should be 1.0):" + str( uN.linkStrength(targetNode, sourceNode))
import conedy as co co.setRandomSeed(0) N = co.network() N.cycle( 1000, 50, co.node(), co.weightedEdge() ) # Creates a closed chain of 1000 nodes where each is connected to its 50 nearest neighbors to each side. print "should be close to 0.75:" + str(N.meanClustering()) print "should be close to " + str(1000.0 / 2 / 100) + ":" + str( N.meanPathLength()) print "should be 100:" + str(N.meanDegree())
import conedy as co N = co.network() N.completeNetwork(10, co.node(), co.weighedEdge()) N.saveAdjacencyList("output/createFromAdjacencyList.py.mat") N.clear() N.createFromAdjacencyList("output/createFromAdjacencyList.py.mat") N.saveAdjacencyList("output/createFromAdjacencyList.py.mat2")
import conedy as co N = co.network() i = N.cycle(20, 1, co.node(), co.weightedEdge()) N.addEdge(i + 1, i + 7, co.weightedEdge(1.0)) N.addEdge(i + 7, i + 1, co.weightedEdge(2.0)) N.addEdge(i + 1, i +11, co.weightedEdge(3.0)) N.addEdge(i +11, i + 1, co.weightedEdge(4.0)) N.betweennessCentrality("output/betweennessCentrality.py.out")
import conedy as co N=co.undirectedNetwork() N.cycle(100, 4, co.node(), co.weightedEdge(0.1)) N.rewire(0.3) print "Initial mean degree:" + str(N.meanDegree()) N.removeRandomEdges(0.5, co.weightedEdge(0.1)) print "Should have changed:" + str(N.meanDegree())
import conedy as co N = co.network() N.torus (40,40,1.5, co.node(), co.weightedEdge(1.0)) #creates a torus of nodes, where each is connected to its 8 (4 direct, 4 diagonal) nearest neighbors print "should be 8:" + str(N.meanDegree()) print "should be "+ str(12.0/28) +":" + str(N.meanClustering())
import conedy as co from os import system n = co.network() networkSize = 10 n.randomNetwork(networkSize, 0.4, co.node(), co.weightedEdge()) n.randomizeWeights(co.uniform(1.1, 1.1)) n.saveAdjacencyList("output/normalizeInputs.co.before") n.normalizeInWeightSum(3.0) print "Should be " + 3.0 / n.meanDegree() + " :" + n.meanWeight() n.saveAdjacencyList("output/normalizeInputs.co.after") system( "sort -n output/normalizeInputs.co.after -k2 > output/normalizeInputs.co.after.sort" )
import conedy as co N = co.network() N.lattice(40, 40, 1.5, co.node(), co.weightedEdge()) print "should be 1600: " + str(N.numberVertices()) N.clear() N.cycle(50, 3, co.node(), co.weightedEdge()) print "should be 50: " + str(N.numberVertices())
import conedy as co N = co.network() N.addNode(co.node()) N.addNode(co.roessler()) N.removeNodes(co.node()) print "Should be 1:" + str(N.numberVertices())
import conedy as co N = co.network() N.completeNetwork (10, co.node(), co.weightedEdge()); N.saveAdjacencyMatrix("output/createFromAdjacencyMatrix.py.mat") N.clear() N.createFromAdjacencyMatrix("output/createFromAdjacencyMatrix.py.mat") N.saveAdjacencyMatrix("output/createFromAdjacencyMatrix.py.mat2")
import conedy as co N = co.network() N.addNode(co.node()) N.addNode() N.addEdge(0, 1, co.weightedEdge(0.3)) N.addEdge(1, 0, co.staticWeightedEdge(0.2)) N.printNodeStatistics() uN = co.undirectedNetwork() sourceNode = uN.addNode(co.node()) targetNode = uN.addNode() # addEdge connects nodes in undirected networks also in the opposite direction. uN.addEdge(sourceNode, targetNode, co.weightedEdge(1.0)) print "linkStrength (should be 1.0):" + str(uN.linkStrength(targetNode, sourceNode))
import conedy as co N = co.network() N.addNode(co.node()) N.addNode() N.addWeightedEdge(0, 1, 0.7) print "Should be 0.7:" + str(N.linkStrength(0, 1))
import conedy as co N = co.network() N.torus( 40, 40, 1.5, co.node(), co.weightedEdge(1.0) ) #creates a torus of nodes, where each is connected to its 8 (4 direct, 4 diagonal) nearest neighbors print "should be 8:" + str(N.meanDegree()) print "should be " + str(12.0 / 28) + ":" + str(N.meanClustering())