/usr/share/pyshared/networkx/drawing/tests/test_agraph.py is in python-networkx 1.6-2.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | """
Unit tests for PyGraphviz intefaace.
"""
import os
import tempfile
from nose import SkipTest
from nose.tools import assert_true
import networkx as nx
class TestAGraph(object):
@classmethod
def setupClass(cls):
global pygraphviz
try:
import pygraphviz
except ImportError:
raise SkipTest('PyGraphviz not available.')
def build_graph(self, G):
G.add_edge('A','B')
G.add_edge('A','C')
G.add_edge('A','C')
G.add_edge('B','C')
G.add_edge('A','D')
G.add_node('E')
return G
def assert_equal(self, G1, G2):
assert_true( sorted(G1.nodes())==sorted(G2.nodes()) )
assert_true( sorted(G1.edges())==sorted(G2.edges()) )
def agraph_checks(self, G):
G = self.build_graph(G)
A=nx.to_agraph(G)
H=nx.from_agraph(A)
self.assert_equal(G, H)
fname=tempfile.mktemp()
nx.drawing.nx_agraph.write_dot(H,fname)
Hin=nx.drawing.nx_agraph.read_dot(fname)
os.unlink(fname)
self.assert_equal(H,Hin)
(fd,fname)=tempfile.mkstemp()
fh=open(fname,'w')
nx.drawing.nx_agraph.write_dot(H,fh)
fh.close()
fh=open(fname,'r')
Hin=nx.drawing.nx_agraph.read_dot(fh)
fh.close()
os.unlink(fname)
self.assert_equal(H,Hin)
def testUndirected(self):
self.agraph_checks(nx.Graph())
def testDirected(self):
self.agraph_checks(nx.DiGraph())
def testMultiUndirected(self):
self.agraph_checks(nx.MultiGraph())
def testMultiDirected(self):
self.agraph_checks(nx.MultiDiGraph())
|