The GraphMLIOHandler
The central class for reading and writing GraphML is the GraphMLIOHandler. Besides its methods for reading and writing graphs it offers a number of customization hooks.
- readFromDocument(graph: IGraph, document: Document): Promise<IGraph>
- readFromGraphMLText(graph: IGraph, data: string): Promise<IGraph>
- readFromURL(graph: IGraph, url: string): Promise<IGraph>
- Parses GraphML from different sources and populates the given graph.
- write(graph: IGraph): Promise<string>
- Returns a promise with the given graph as GraphML string.
By default the GraphMLIOHandler reads and writes GraphML which encodes all structural, visual, and geometric information of a graph. You can easily configure the GraphMLIOHandler to write additional business data which is associated with graph elements or the graph itself. These data can be of simple type like string, e.g. encoding a tooltip or a link. It is also possible, though, to encode complex data like objects which model the entire business data behind a graph item.
Customizing GraphMLIOHandler
To use a customized GraphMLIOHandler with a GraphComponent, you can set its property GraphMLSupport.graphMLIOHandler:
Events for Reading and Writing
GraphMLIOHandler facilitates events that are fired at different stages of reading or writing. The most common use case is to perform an action after a graph is loaded, for example to apply a layout algorithm to the loaded graph.