C# Class Smrf.NodeXL.Adapters.GraphMLGraphAdapter

Converts a graph to and from a GraphML file.
A good introduction to GraphML can be found in the GraphML Primer:

http://graphml.graphdrawing.org/primer/graphml-primer.html

Here is a sample GraphML file that can be converted. It represents a graph with three vertices and two edges.

<?xml version="1.0" encoding="UTF-8"?> <graphml xmlns="http://graphml.graphdrawing.org/xmlns"> <key id="EdgeWidth" for="edge" attr.name="Width" attr.type="double"> <default>1.5</default> </key> <key id="VertexColor" for="node" attr.name="Color" attr.type="string" /> <key id="LatestPostDate" for="node" attr.name="Latest Post Date" attr.type="string" /> <graph edgedefault="undirected"> <node id="V1"> <data key="VertexColor">red</data> </node> <node id="V2"> <data key="VertexColor">orange</data> </node> <node id="V3"> <data key="VertexColor">blue</data> </node> <edge source="V1" target="V2"> <data key="LatestPostDate">2009/07/05</data> </edge> <edge source="V3" target="V2"> <data key="EdgeWidth">2.5</data> <data key="LatestPostDate">2009/07/12</data> </edge> </graph> </graphml>

Edge and vertex attributes, which GraphML calls "GraphML-attributes," are supported by this class. When loading a graph, if an edge or vertex has a GraphML-attribute, it gets added to the metadata of the or IVertex. The metadata key is the GraphML-attribute's attr.name value and the metadata value is the GraphML-attribute's value. When saving a graph, every metadata value on every edge and vertex gets converted to a GraphML-attribute in the saved GraphML.

To make it possible for the caller to determine which metadata keys were added to the graph's edges and vertices, the LoadXX methods add and keys to the returned graph. The key values are of type String[].

If there is an optional "description" attribute on the "graph" XML node, the LoadXX methods copy its value to a key on the returned graph.

If there is an optional "suggestedFileNameNoExtension" attribute on the "graph" XML node, the LoadXX methods copy its value to a key on the returned graph.

When saving a graph, the caller must add and keys to the graph before calling IGraphAdapter.SaveGraph(IGraph, Stream).

Inheritance: GraphAdapterBase, IGraphAdapter
Afficher le fichier Open project: 2014-sed-team3/term-project Class Usage Examples

Méthodes publiques

Méthode Description
AssertValid ( ) : void
GraphMLGraphAdapter ( ) : System

Initializes a new instance of the GraphMLGraphAdapter class.

Méthodes protégées

Méthode Description
AppendGraphMLAttributeValues ( IMetadataProvider oEdgeOrVertex, GraphMLXmlDocument oGraphMLXmlDocument, XmlNode oEdgeOrVertexXmlNode, String asAttributeNames, String AttributeIDPrefix ) : void
GetGraphDirectedness ( XmlNode oGraphXmlNode ) : GraphDirectedness
GetSupportedDirectedness ( System.Boolean &supportsDirected, System.Boolean &supportsUndirected, System.Boolean &supportsMixed ) : void
LoadGraphCore ( Stream stream ) : IGraph
ParseEdges ( IGraph oGraph, XmlNode oGraphXmlNode, XmlNamespaceManager oXmlNamespaceManager, IVertex>.Dictionary oVertexDictionary, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
ParseGraphAttribute ( IGraph oGraph, XmlNode oGraphXmlNode, String sXmlAttributeName, String sKey ) : void
ParseGraphMLAttributeDefinitions ( XmlNode oGraphMLXmlNode, XmlNamespaceManager oXmlNamespaceManager ) : GraphMLAttribute>.Dictionary
ParseGraphMLAttributeValues ( XmlNode oNodeOrEdgeXmlNode, XmlNamespaceManager oXmlNamespaceManager, IMetadataProvider oEdgeOrVertex, System.Boolean bIsVertex, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
ParseVertices ( IGraph oGraph, XmlNode oGraphXmlNode, XmlNamespaceManager oXmlNamespaceManager, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : IVertex>.Dictionary
SaveGraphCore ( IGraph graph, Stream stream ) : void
SaveGraphMLAttributeNames ( IGraph oGraph, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
TryGraphMLNodeIDToVertex ( XmlNode oEdgeXmlNode, String sSourceOrTarget, IVertex>.Dictionary oVertexDictionary, IVertex &oVertex ) : System.Boolean

Method Details

AppendGraphMLAttributeValues() protected méthode

protected AppendGraphMLAttributeValues ( IMetadataProvider oEdgeOrVertex, GraphMLXmlDocument oGraphMLXmlDocument, XmlNode oEdgeOrVertexXmlNode, String asAttributeNames, String AttributeIDPrefix ) : void
oEdgeOrVertex IMetadataProvider
oGraphMLXmlDocument Smrf.XmlLib.GraphMLXmlDocument
oEdgeOrVertexXmlNode System.Xml.XmlNode
asAttributeNames String
AttributeIDPrefix String
Résultat void

AssertValid() public méthode

public AssertValid ( ) : void
Résultat void

GetGraphDirectedness() protected méthode

protected GetGraphDirectedness ( XmlNode oGraphXmlNode ) : GraphDirectedness
oGraphXmlNode System.Xml.XmlNode
Résultat GraphDirectedness

GetSupportedDirectedness() protected méthode

protected GetSupportedDirectedness ( System.Boolean &supportsDirected, System.Boolean &supportsUndirected, System.Boolean &supportsMixed ) : void
supportsDirected System.Boolean
supportsUndirected System.Boolean
supportsMixed System.Boolean
Résultat void

GraphMLGraphAdapter() public méthode

Initializes a new instance of the GraphMLGraphAdapter class.
public GraphMLGraphAdapter ( ) : System
Résultat System

LoadGraphCore() protected méthode

protected LoadGraphCore ( Stream stream ) : IGraph
stream Stream
Résultat IGraph

ParseEdges() protected méthode

protected ParseEdges ( IGraph oGraph, XmlNode oGraphXmlNode, XmlNamespaceManager oXmlNamespaceManager, IVertex>.Dictionary oVertexDictionary, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
oGraph IGraph
oGraphXmlNode System.Xml.XmlNode
oXmlNamespaceManager System.Xml.XmlNamespaceManager
oVertexDictionary IVertex>.Dictionary
oGraphMLAttributeDictionary GraphMLAttribute>.Dictionary
Résultat void

ParseGraphAttribute() protected méthode

protected ParseGraphAttribute ( IGraph oGraph, XmlNode oGraphXmlNode, String sXmlAttributeName, String sKey ) : void
oGraph IGraph
oGraphXmlNode System.Xml.XmlNode
sXmlAttributeName String
sKey String
Résultat void

ParseGraphMLAttributeDefinitions() protected méthode

protected ParseGraphMLAttributeDefinitions ( XmlNode oGraphMLXmlNode, XmlNamespaceManager oXmlNamespaceManager ) : GraphMLAttribute>.Dictionary
oGraphMLXmlNode System.Xml.XmlNode
oXmlNamespaceManager System.Xml.XmlNamespaceManager
Résultat GraphMLAttribute>.Dictionary

ParseGraphMLAttributeValues() protected méthode

protected ParseGraphMLAttributeValues ( XmlNode oNodeOrEdgeXmlNode, XmlNamespaceManager oXmlNamespaceManager, IMetadataProvider oEdgeOrVertex, System.Boolean bIsVertex, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
oNodeOrEdgeXmlNode System.Xml.XmlNode
oXmlNamespaceManager System.Xml.XmlNamespaceManager
oEdgeOrVertex IMetadataProvider
bIsVertex System.Boolean
oGraphMLAttributeDictionary GraphMLAttribute>.Dictionary
Résultat void

ParseVertices() protected méthode

protected ParseVertices ( IGraph oGraph, XmlNode oGraphXmlNode, XmlNamespaceManager oXmlNamespaceManager, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : IVertex>.Dictionary
oGraph IGraph
oGraphXmlNode System.Xml.XmlNode
oXmlNamespaceManager System.Xml.XmlNamespaceManager
oGraphMLAttributeDictionary GraphMLAttribute>.Dictionary
Résultat IVertex>.Dictionary

SaveGraphCore() protected méthode

protected SaveGraphCore ( IGraph graph, Stream stream ) : void
graph IGraph
stream Stream
Résultat void

SaveGraphMLAttributeNames() protected méthode

protected SaveGraphMLAttributeNames ( IGraph oGraph, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
oGraph IGraph
oGraphMLAttributeDictionary GraphMLAttribute>.Dictionary
Résultat void

TryGraphMLNodeIDToVertex() protected méthode

protected TryGraphMLNodeIDToVertex ( XmlNode oEdgeXmlNode, String sSourceOrTarget, IVertex>.Dictionary oVertexDictionary, IVertex &oVertex ) : System.Boolean
oEdgeXmlNode System.Xml.XmlNode
sSourceOrTarget String
oVertexDictionary IVertex>.Dictionary
oVertex IVertex
Résultat System.Boolean