# Path: apgl/io/SimpleGraphReader.py
# class SimpleGraphReader(GraphReader):
#         '''
#         A class to read SimpleGraph files.
#         '''
#         def __init__(self):
#             pass
# 
#         def readFromFile(self, fileName):
#             """
#             Read vertices and edges of the graph from the given file name. The file
#             must have as its first line "Vertices" followed by a list of
#             vertex indices (one per line). Then the lines following "Arcs" or "Edges"
#             have a list of pairs of vertex indices represented directed or undirected
#             edges.
#             """
#             infile = open(fileName, "r")
#             line = infile.readline()
#             line = infile.readline()
#             ind = 0
#             vertexIdDict = {}
# 
#             while infile and line != "Edges" and line != "Arcs":
#                 vertexIdDict[int(line)] = ind
#                 line = infile.readline().strip()
#                 ind += 1 
# 
#             if line == "Edges":
#                 undirected = True
#             elif line == "Arcs":
#                 undirected = False
#             else:
#                 raise ValueError("Unknown edge types: " + line)
# 
#             numVertices = len(vertexIdDict)
#             numFeatures = 0
#             vList = VertexList(numVertices, numFeatures)
#             sGraph = SparseGraph(vList, undirected)
#             line = infile.readline()
# 
#             while line:
#                 s = line.split()
#                 try:
#                     i = vertexIdDict[int(s[0].strip(',').strip())]
#                     j = vertexIdDict[int(s[1].strip(',').strip())]
#                     k = float(s[2].strip(',').strip())
#                 except KeyError:
#                     print("Vertex not found in list of vertices.")
#                     raise 
# 
#                 sGraph.addEdge(i, j, k)
#                 line = infile.readline()
# 
#             logging.info("Read graph with " + str(numVertices) + " vertices and " + str(sGraph.getNumEdges()) + " edges")
# 
#             return sGraph
# 
# Path: apgl/util/PathDefaults.py
# class PathDefaults(object):
#     """
#     This class stores some useful global default paths. 
#     """
#     @staticmethod 
#     def readField(field):
#         configFileName = expanduser("~") + os.sep + ".apglrc"
# 
#         if not os.path.exists(configFileName): 
#             print("Creating missing config file: " + configFileName)
#             defaultConfig = "[paths]\n" 
#             defaultConfig += "data = " + expanduser("~") + os.sep + "data" + os.sep + "\n"
#             defaultConfig += "output = " + expanduser("~") + os.sep + "output" + os.sep + "\n"
#             configFile = open(configFileName, "w")
#             configFile.write(defaultConfig)
#             configFile.close()
#             
#         parser = SafeConfigParser()
#         parser.read(configFileName)
#         return parser.get('paths', field)
# 
#     @staticmethod
#     def getSourceDir():
#         """
#         Root directory of source code for APGL. 
#         """
#         dir = os.path.abspath( __file__ )
#         dir, head = os.path.split(dir)
#         dir, head = os.path.split(dir)
#         return dir 
#         
#     @staticmethod
#     def getDataDir():
#         """
#         Location of data files. 
#         """
#         return PathDefaults.readField("data")
# 
#     @staticmethod
#     def getOutputDir():
#         """
#         Location of output files. 
#         """
#         return PathDefaults.readField("output")
#         
#     @staticmethod
#     def getTempDir():
#         return tempfile.gettempdir() + os.sep


import unittest
import logging
from apgl.io.SimpleGraphReader import SimpleGraphReader
from apgl.util.PathDefaults import PathDefaults 




class  SimpleGraphReaderTest(unittest.TestCase):
    def testReadGraph(self):
        fileName = PathDefaults.getDataDir() +  "test/simpleGraph.txt"


# Path: apgl/io/SimpleGraphReader.py
# class SimpleGraphReader(GraphReader):
#         '''
#         A class to read SimpleGraph files.
#         '''
#         def __init__(self):
#             pass
# 
#         def readFromFile(self, fileName):
#             """
#             Read vertices and edges of the graph from the given file name. The file
#             must have as its first line "Vertices" followed by a list of
#             vertex indices (one per line). Then the lines following "Arcs" or "Edges"
#             have a list of pairs of vertex indices represented directed or undirected
#             edges.
#             """
#             infile = open(fileName, "r")
#             line = infile.readline()
#             line = infile.readline()
#             ind = 0
#             vertexIdDict = {}
# 
#             while infile and line != "Edges" and line != "Arcs":
#                 vertexIdDict[int(line)] = ind
#                 line = infile.readline().strip()
#                 ind += 1 
# 
#             if line == "Edges":
#                 undirected = True
#             elif line == "Arcs":
#                 undirected = False
#             else:
#                 raise ValueError("Unknown edge types: " + line)
# 
#             numVertices = len(vertexIdDict)
#             numFeatures = 0
#             vList = VertexList(numVertices, numFeatures)
#             sGraph = SparseGraph(vList, undirected)
#             line = infile.readline()
# 
#             while line:
#                 s = line.split()
#                 try:
#                     i = vertexIdDict[int(s[0].strip(',').strip())]
#                     j = vertexIdDict[int(s[1].strip(',').strip())]
#                     k = float(s[2].strip(',').strip())
#                 except KeyError:
#                     print("Vertex not found in list of vertices.")
#                     raise 
# 
#                 sGraph.addEdge(i, j, k)
#                 line = infile.readline()
# 
#             logging.info("Read graph with " + str(numVertices) + " vertices and " + str(sGraph.getNumEdges()) + " edges")
# 
#             return sGraph
# 
# Path: apgl/util/PathDefaults.py
# class PathDefaults(object):
#     """
#     This class stores some useful global default paths. 
#     """
#     @staticmethod 
#     def readField(field):
#         configFileName = expanduser("~") + os.sep + ".apglrc"
# 
#         if not os.path.exists(configFileName): 
#             print("Creating missing config file: " + configFileName)
#             defaultConfig = "[paths]\n" 
#             defaultConfig += "data = " + expanduser("~") + os.sep + "data" + os.sep + "\n"
#             defaultConfig += "output = " + expanduser("~") + os.sep + "output" + os.sep + "\n"
#             configFile = open(configFileName, "w")
#             configFile.write(defaultConfig)
#             configFile.close()
#             
#         parser = SafeConfigParser()
#         parser.read(configFileName)
#         return parser.get('paths', field)
# 
#     @staticmethod
#     def getSourceDir():
#         """
#         Root directory of source code for APGL. 
#         """
#         dir = os.path.abspath( __file__ )
#         dir, head = os.path.split(dir)
#         dir, head = os.path.split(dir)
#         return dir 
#         
#     @staticmethod
#     def getDataDir():
#         """
#         Location of data files. 
#         """
#         return PathDefaults.readField("data")
# 
#     @staticmethod
#     def getOutputDir():
#         """
#         Location of output files. 
#         """
#         return PathDefaults.readField("output")
#         
#     @staticmethod
#     def getTempDir():
#         return tempfile.gettempdir() + os.sep


# Path: apgl/io/test/SimpleGraphReaderTest.py
import unittest
import logging
from apgl.io.SimpleGraphReader import SimpleGraphReader
from apgl.util.PathDefaults import PathDefaults 





class  SimpleGraphReaderTest(unittest.TestCase):
    def testReadGraph(self):
        fileName = PathDefaults.getDataDir() +  "test/simpleGraph.txt"


        graphReader = SimpleGraphReader()