/usr/share/pyshared/igraph/test/indexing.py is in python-igraph 0.6.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # vim:ts=4 sw=4 sts=4:
import unittest
from igraph import *
class GraphAdjacencyMatrixLikeIndexingTests(unittest.TestCase):
def testSingleEdgeRetrieval(self):
g = Graph.Famous("krackhardt_kite")
for v1, v2 in g.get_edgelist():
self.assertEquals(g[v1, v2], 1)
self.assertEquals(g[v2, v1], 1)
for v1 in xrange(g.vcount()):
for v2 in set(range(g.vcount())) - set(g.neighbors(v1)):
self.assertEquals(g[v1, v2], 0)
self.assertEquals(g[v2, v1], 0)
g.add_edge(1, 1)
self.assertEquals(g[1, 1], 1)
def testSingleEdgeRetrievalWeights(self):
g = Graph.Famous("krackhardt_kite")
g.es["weight"] = range(g.ecount())
for idx, (v1, v2) in enumerate(g.get_edgelist()):
self.assertEquals(g[v1, v2], idx)
self.assertEquals(g[v2, v1], idx)
for v1 in xrange(g.vcount()):
for v2 in set(range(g.vcount())) - set(g.neighbors(v1)):
self.assertEquals(g[v1, v2], 0)
self.assertEquals(g[v2, v1], 0)
def testSingleEdgeRetrievalAttrName(self):
g = Graph.Famous("krackhardt_kite")
g.es["value"] = range(20, g.ecount()+20)
for idx, (v1, v2) in enumerate(g.get_edgelist()):
self.assertEquals(g[v1, v2, "value"], idx+20)
self.assertEquals(g[v2, v1, "value"], idx+20)
for v1 in xrange(g.vcount()):
for v2 in set(range(g.vcount())) - set(g.neighbors(v1)):
self.assertEquals(g[v1, v2, "value"], 0)
self.assertEquals(g[v2, v1, "value"], 0)
def suite():
adjacency_suite = unittest.makeSuite(GraphAdjacencyMatrixLikeIndexingTests)
return unittest.TestSuite([adjacency_suite])
def test():
runner = unittest.TextTestRunner()
runner.run(suite())
if __name__ == "__main__":
test()
|