本文整理汇总了C#中AdjacencyGraph.SerializeToGraphML方法的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph.SerializeToGraphML方法的具体用法?C# AdjacencyGraph.SerializeToGraphML怎么用?C# AdjacencyGraph.SerializeToGraphML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdjacencyGraph
的用法示例。
在下文中一共展示了AdjacencyGraph.SerializeToGraphML方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PersistGraph
/// <summary>
/// Saves the graph in the GraphML format in the specified filename
/// </summary>
/// <param name="graph">
/// The graph to persist
/// </param>
/// <param name="options">
/// The core options used to get information about the graph to generate
/// </param>
public void PersistGraph(AdjacencyGraph<VisualStudioProject, Edge<VisualStudioProject>> graph, IMsBuilderificCoreOptions options)
{
using (var xwriter = XmlWriter.Create(options.GraphFilename))
graph.SerializeToGraphML<VisualStudioProject, Edge<VisualStudioProject>, AdjacencyGraph<VisualStudioProject, Edge<VisualStudioProject>>>(xwriter, s => s.AssemblyName, e => String.Format("{0} depends on {1}", e.Source.AssemblyName, e.Target.AssemblyName));
}
示例2: WriteGraph
private void WriteGraph(string filename, AdjacencyGraph<Node, Edge<Node>> graph)
{
var settings = new XmlWriterSettings
{
Indent = true,
IndentChars = " ",
};
using (var writer = XmlWriter.Create(filename, settings))
{
graph.SerializeToGraphML<Node, Edge<Node>, AdjacencyGraph<Node, Edge<Node>>>(writer);
}
}
示例3: GenerateGraphML
public static void GenerateGraphML(string fileName)
{
var graph = new AdjacencyGraph<XOVertex, XOEdge>();
var relationshipsSubset = _relationships.Values
//.Where(e => e.Source.ModuleId == "57$61" && e.Target.ModuleId == "57$61")
.Where(e => (e.Source.ClassSpec == "Audited" || e.Source.ClassSpec == "Metadata") && (e.Target.ClassSpec == "Audited" || e.Target.ClassSpec == "Metadata"))
.ToArray();
foreach (var r in relationshipsSubset)
{
if (!graph.ContainsVertex(r.Source))
graph.AddVertex(r.Source);
if (!graph.ContainsVertex(r.Target))
graph.AddVertex(r.Target);
}
graph.AddEdgeRange(relationshipsSubset);
int idx = 0;
foreach (var v in graph.Vertices)
{
foreach (var super in v.Superclasses.Select(s => _classes[s]).Where(s => graph.ContainsVertex(s)))
{
string id = string.Concat("inheritance_", idx++);
graph.AddEdge(new XOEdge(id, v, super)
{
Weight = BuildEdgeWeight(v, super),
EdgeType = BuildEdgeInheritanceType(v, super),
Color = BuildEdgeInheritanceColor(v, super)
});
}
}
VertexIdentity<XOVertex> vi = v => v.Id;
EdgeIdentity<XOVertex, XOEdge> ei = e => e.Id;
using (XmlWriter xw = XmlWriter.Create(fileName))
{
graph.SerializeToGraphML<XOVertex, XOEdge, AdjacencyGraph<XOVertex, XOEdge>>(xw, vi, ei);
}
}
示例4: SaveGraphToFile
public static void SaveGraphToFile(AdjacencyGraph<string, Edge<string>> graph, string targetPath)
{
// Save the graph
using (var xwriter = XmlWriter.Create(File.CreateText(targetPath)))
graph.SerializeToGraphML<string, Edge<string>, AdjacencyGraph<string, Edge<string>>>(xwriter);
}