Parsing GrAFΒΆ

The first step is to initialize the parser:

   import graf
   gparser = graf.GraphParser()

You can then directly pass the filename of the GrAF header to the parser:
graph = gparser.parse("filename.hdr")

The parser then collects all the dependencies from this header. You might also pass the file name of any GrAF/XML file to the parser. The parser then loads all files that are dependencies of that file as described in its header.

Alternativily the parser also accepts and open file stream. Now we have a GrAF object and it is possible to verify the nodes, regions, edges and their respectives annotations.

# Checking the nodes
for node in graph.nodes():

# Checking the regions
for region in graph.regions():

# Checking the edges
for edge in graph.edges():