def testLoad(self):
        try:
            numVertices = 10
            numFeatures = 1
            vList = VertexList(numVertices, numFeatures)
            vList.setVertices(numpy.random.rand(numVertices, numFeatures))

            graph = self.GraphType(vList, True)
            graph.addEdge(0, 1, 0.1)
            graph.addEdge(1, 2, 0.2)
            graph.addEdge(1, 3, 0.3)

            tempDir = PathDefaults.getTempDir()
            tempFile = tempDir + "testGraph"

            graph.save(tempFile)

            dataDir = PathDefaults.getDataDir()
            os.chdir(dataDir)
            currentPath = os.getcwd()
            graph2 = self.GraphType.load(tempFile)

            #Make sure save doesn't change the path
            self.assertEquals(os.getcwd(), currentPath)

            self.assertEquals(graph.getNumVertices(), graph.getNumVertices())
            self.assertEquals(graph.getNumEdges(), graph.getNumEdges())
            self.assertTrue(graph2.isUndirected() == True)
            self.assertTrue((graph.getVertexList().getVertices(list(range(numVertices))) == graph2.getVertexList().getVertices(list(range(numVertices)))).all())
            self.assertTrue((graph.getAllEdges() == graph2.getAllEdges()).all())
            self.assertTrue(graph2.getEdge(0, 1) == 0.1)
            self.assertTrue(graph2.getEdge(1, 2) == 0.2)
            self.assertTrue(graph2.getEdge(1, 3) == 0.3)

            #Test if loading of old-style graph files works
            testDir = PathDefaults.getDataDir() + "test/"
            graphFilename = testDir + "fd"

            graph = self.GraphType.load(graphFilename)

            self.assertEquals(graph.getEdge(1, 1), 1)
            self.assertEquals(graph.getEdge(2, 2), 1)
            self.assertEquals(graph.getNumVertices(), 10)
        except IOError as e:
            logging.warn(e)
            pass
        except __HOLE__ as e:
            logging.warn(e)
            pass
dataset/ETHPy150Open charanpald/APGL/apgl/graph/test/MatrixGraphTest.py/MatrixGraphTest.testLoad