C# Класс 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).

Наследование: GraphAdapterBase, IGraphAdapter
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AssertValid ( ) : void
GraphMLGraphAdapter ( ) : System

Initializes a new instance of the GraphMLGraphAdapter class.

Защищенные методы

Метод Описание
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

Описание методов

AppendGraphMLAttributeValues() защищенный Метод

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
Результат void

AssertValid() публичный Метод

public AssertValid ( ) : void
Результат void

GetGraphDirectedness() защищенный Метод

protected GetGraphDirectedness ( XmlNode oGraphXmlNode ) : GraphDirectedness
oGraphXmlNode System.Xml.XmlNode
Результат GraphDirectedness

GetSupportedDirectedness() защищенный Метод

protected GetSupportedDirectedness ( System.Boolean &supportsDirected, System.Boolean &supportsUndirected, System.Boolean &supportsMixed ) : void
supportsDirected System.Boolean
supportsUndirected System.Boolean
supportsMixed System.Boolean
Результат void

GraphMLGraphAdapter() публичный Метод

Initializes a new instance of the GraphMLGraphAdapter class.
public GraphMLGraphAdapter ( ) : System
Результат System

LoadGraphCore() защищенный Метод

protected LoadGraphCore ( Stream stream ) : IGraph
stream Stream
Результат IGraph

ParseEdges() защищенный Метод

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
Результат void

ParseGraphAttribute() защищенный Метод

protected ParseGraphAttribute ( IGraph oGraph, XmlNode oGraphXmlNode, String sXmlAttributeName, String sKey ) : void
oGraph IGraph
oGraphXmlNode System.Xml.XmlNode
sXmlAttributeName String
sKey String
Результат void

ParseGraphMLAttributeDefinitions() защищенный Метод

protected ParseGraphMLAttributeDefinitions ( XmlNode oGraphMLXmlNode, XmlNamespaceManager oXmlNamespaceManager ) : GraphMLAttribute>.Dictionary
oGraphMLXmlNode System.Xml.XmlNode
oXmlNamespaceManager System.Xml.XmlNamespaceManager
Результат GraphMLAttribute>.Dictionary

ParseGraphMLAttributeValues() защищенный Метод

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
Результат void

ParseVertices() защищенный Метод

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
Результат IVertex>.Dictionary

SaveGraphCore() защищенный Метод

protected SaveGraphCore ( IGraph graph, Stream stream ) : void
graph IGraph
stream Stream
Результат void

SaveGraphMLAttributeNames() защищенный Метод

protected SaveGraphMLAttributeNames ( IGraph oGraph, GraphMLAttribute>.Dictionary oGraphMLAttributeDictionary ) : void
oGraph IGraph
oGraphMLAttributeDictionary GraphMLAttribute>.Dictionary
Результат void

TryGraphMLNodeIDToVertex() защищенный Метод

protected TryGraphMLNodeIDToVertex ( XmlNode oEdgeXmlNode, String sSourceOrTarget, IVertex>.Dictionary oVertexDictionary, IVertex &oVertex ) : System.Boolean
oEdgeXmlNode System.Xml.XmlNode
sSourceOrTarget String
oVertexDictionary IVertex>.Dictionary
oVertex IVertex
Результат System.Boolean