本文整理汇总了C#中IGraph.GetRequiredValue方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.GetRequiredValue方法的具体用法?C# IGraph.GetRequiredValue怎么用?C# IGraph.GetRequiredValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.GetRequiredValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveGraphCore
//*************************************************************************
// Method: SaveGraphCore()
//
/// <summary>
/// Saves graph data to a stream.
/// </summary>
///
/// <param name="graph">
/// Graph to save.
/// </param>
///
/// <param name="stream">
/// Stream to save the graph data to.
/// </param>
///
/// <remarks>
/// This method saves <paramref name="graph" /> to <paramref
/// name="stream" />. It does not close <paramref name="stream" />.
///
/// <para>
/// The arguments have already been checked for validity.
/// </para>
///
/// </remarks>
//*************************************************************************
protected override void SaveGraphCore(
IGraph graph,
Stream stream
)
{
Debug.Assert(graph != null);
Debug.Assert(stream != null);
AssertValid();
GraphMLXmlDocument oGraphMLXmlDocument = new GraphMLXmlDocument(
graph.Directedness == GraphDirectedness.Directed);
String [] asEdgeAttributeNames = ( String[] )graph.GetRequiredValue(
ReservedMetadataKeys.AllEdgeMetadataKeys, typeof( String[] ) );
String [] asVertexAttributeNames = ( String[] )graph.GetRequiredValue(
ReservedMetadataKeys.AllVertexMetadataKeys, typeof( String[] ) );
// Define the Graph-ML attributes.
const String VertexAttributeIDPrefix = "V-";
const String EdgeAttributeIDPrefix = "E-";
foreach (String sVertexAttributeName in asVertexAttributeNames)
{
oGraphMLXmlDocument.DefineGraphMLAttribute(false,
VertexAttributeIDPrefix + sVertexAttributeName,
sVertexAttributeName, "string", null);
}
foreach (String sEdgeAttributeName in asEdgeAttributeNames)
{
oGraphMLXmlDocument.DefineGraphMLAttribute(true,
EdgeAttributeIDPrefix + sEdgeAttributeName,
sEdgeAttributeName, "string", null);
}
// Add the vertices and their Graph-ML attribute values.
foreach (IVertex oVertex in graph.Vertices)
{
XmlNode oVertexXmlNode = oGraphMLXmlDocument.AppendVertexXmlNode(
oVertex.Name);
AppendGraphMLAttributeValues(oVertex, oGraphMLXmlDocument,
oVertexXmlNode, asVertexAttributeNames,
VertexAttributeIDPrefix);
}
// Add the edges and their Graph-ML attribute values.
foreach (IEdge oEdge in graph.Edges)
{
IVertex [] oVertices = oEdge.Vertices;
XmlNode oEdgeXmlNode = oGraphMLXmlDocument.AppendEdgeXmlNode(
oVertices[0].Name, oVertices[1].Name);
AppendGraphMLAttributeValues(oEdge, oGraphMLXmlDocument,
oEdgeXmlNode, asEdgeAttributeNames, EdgeAttributeIDPrefix);
}
oGraphMLXmlDocument.Save(stream);
}
示例2: AssertValid
GetAttributeNames
(
IGraph graph,
Boolean forVertices
)
{
Debug.Assert(graph != null);
AssertValid();
return ( ( String[] )graph.GetRequiredValue(
forVertices ?
ReservedMetadataKeys.AllVertexMetadataKeys
:
ReservedMetadataKeys.AllEdgeMetadataKeys,
typeof( String[] ) ) );
}