本文整理汇总了C#中AdjacencyGraph类的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph类的具体用法?C# AdjacencyGraph怎么用?C# AdjacencyGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AdjacencyGraph类属于命名空间,在下文中一共展示了AdjacencyGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindAllPatterns
/// <summary>
/// Przerabia graf na string z odnalezionymi paternami
/// </summary>
/// <param name="g"></param>
/// <returns></returns>
public string FindAllPatterns(AdjacencyGraph<Node, Edge<Node>> g)
{
bool nodesStillInGraph = true;
while (nodesStillInGraph)
{
var decisionNodes = g.Vertices.Where(x => x.Type == NodeType.DecisionNode).ToList();
var forkNodes = g.Vertices.Where(x => x.Type == NodeType.ForkNode).ToList();
if (decisionNodes.Count == 0 && forkNodes.Count == 0)
{
nodesStillInGraph = false;
continue;
}
g = FindLoopPattern(g);
g = FindSeqPattern(g);
g = FindDecisionPattern(g);
g = FindSeqPattern(g);
g = FindParPattern(g);
g = FindSeqPattern(g);
}
if (g.Vertices.Count() == 3 && g.Edges.Count() == 2)
{
var start = g.Vertices.Where(x => x.Type == NodeType.InitalNode).ToList().FirstOrDefault();
var end = g.Vertices.Where(x => x.Type == NodeType.ActivityFinalNode).ToList().FirstOrDefault();
var body = g.Vertices.Where(x => x != start && x != end).ToList().FirstOrDefault();
return "seqseq(" + start.Name + "," + body.Name + "," + end.Name + ")";
}
return "ERROR";
}
示例2: Simple
public void Simple()
{
AdjacencyGraph<string, Edge<string>> g = new AdjacencyGraph<string, Edge<string>>();
GraphFactory.Simple(g);
this.Compute(g);
this.ComputeCriticalPath(g);
}
示例3: createGraphWizDotFile
//DC this version was using the old QuickGraph MarkedEdge
public static void createGraphWizDotFile(AdjacencyGraph<String, TaggedEdge<String, String>> gGraphWizToPopulate,
TreeNode tnTreeNode, bool bOrder, bool bFilterName, bool bFilterClass,
int iFilterClassLevel)
{
if (bFilterClass)
tnTreeNode.Text = FilteredSignature.filterName(tnTreeNode.Text, false, false, true, 0, true, true,
iFilterClassLevel);
TaggedEdge<String, string> meTemp;
if (gGraphWizToPopulate.ContainsVertex(tnTreeNode.Text))
{
}
else
gGraphWizToPopulate.AddVertex(tnTreeNode.Text);
foreach (TreeNode tnChild in tnTreeNode.Nodes)
{
if (bFilterClass)
tnChild.Text = FilteredSignature.filterName(tnChild.Text, false, false, true, 0, true, true,
iFilterClassLevel);
createGraphWizDotFile(gGraphWizToPopulate, tnChild, bOrder, bFilterName, bFilterClass, iFilterClassLevel);
if (bOrder)
{
if (false == gGraphWizToPopulate.TryGetEdge(tnTreeNode.Text, tnChild.Text, out meTemp))
gGraphWizToPopulate.AddEdge(new TaggedEdge<String, string>(tnTreeNode.Text, tnChild.Text,
"marker"));
}
else if (false == gGraphWizToPopulate.TryGetEdge(tnChild.Text, tnTreeNode.Text, out meTemp))
gGraphWizToPopulate.AddEdge(new TaggedEdge<String, string>(tnChild.Text, tnTreeNode.Text, "marker"));
//gGraphToPopulate.AddEdge(tnTreeNode.Text, tnChild.Text);
// gGraphToPopulate.AddEdge(Analysis_CallFlow.display.filterName(tnChild.Text, false, false, false), Analysis_CallFlow.display.filterName(tnTreeNode.Text, false, false, false));
//else
}
}
示例4: BuildReferencesGraph
private static AdjacencyGraph<string, Edge<string>> BuildReferencesGraph(out Dictionary<string, string> servers)
{
servers = new Dictionary<string, string>();
var graph = new AdjacencyGraph<string, Edge<string>>();
foreach (var serverName in Args.ServerNames.Split('|'))
{
var projectsPath = Paths.ProjectsFolder(serverName);
foreach (var projectFolder in Directory.GetDirectories(projectsPath))
{
var projectName = Path.GetFileName(projectFolder);
var referencesFolder = Path.Combine(projectFolder, Args.ReferencesFolder);
servers.Add(projectName, serverName);
if (!Directory.Exists(referencesFolder))
continue;
var referenceFiles = Directory.GetFiles(referencesFolder).Select(Path.GetFileNameWithoutExtension);
graph.AddVerticesAndEdgeRange(referenceFiles.Select(referenceName => new Edge<string>(referenceName, projectName)));
}
}
return graph;
}
示例5: ParkingMap
public ParkingMap(string name, int width, int height)
{
Name = name;
Width = width;
Height = height;
Graph = new AdjacencyGraph<Vertex, Edge<Vertex>>();
}
示例6: BuildDependencyGraph
public static AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>> BuildDependencyGraph(Type viewModelType)
{
var directDependencies = ViewModelConventions.GetViewModelProperties(viewModelType).ToDictionary(p => p, GetDirectDependentProperties);
var graph = new AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>>();
foreach (var directDependency in directDependencies)
{
var property = directDependency.Key;
graph.AddVertex(property);
foreach (var dependentProperty in directDependency.Value)
{
var sub = dependentProperty.SubPath;
var propertyType = property.PropertyType;
if (GetCollectionType(propertyType) != null) propertyType = GetCollectionType(propertyType);
if (String.IsNullOrEmpty(sub) && ViewModelConventions.IsViewModel(propertyType))
sub = "*";
graph.AddEdge(new STaggedEdge<PropertyInfo, string>(property, dependentProperty.Property, sub));
}
}
return graph;
}
示例7: QGPathFinder
public QGPathFinder(Status status, MainForm parent)
{
m_parent = parent;
m_status = status;
graph = new AdjacencyGraph<string, Edge<string>>(true);
edgeCost = new Dictionary<Edge<string>, double>(graph.EdgeCount);
this.fp = m_status.floorPlan;
if (this.m_status.position != null)
{
startPoint = this.m_status.position.location.X + "_" + this.m_status.position.location.Y;
m_parent.PostMessage("start: " + startPoint);
}
else
{
startPoint = "4_4";
}
if (this.m_status.endPoint!= null)
{
targetPoint = this.m_status.endPoint.X + "_" + this.m_status.endPoint.Y;
m_parent.PostMessage("end: " + targetPoint);
}
else
{
targetPoint = "4_6";
}
buildGraph();
}
示例8: CheckPredecessorLineGraph
public void CheckPredecessorLineGraph()
{
AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
g.AddVertex(1);
g.AddVertex(2);
g.AddVertex(3);
Edge<int> e12 = new Edge<int>(1, 2); g.AddEdge(e12);
Edge<int> e23 = new Edge<int>(2, 3); g.AddEdge(e23);
Dictionary<Edge<int>, double> weights =
DijkstraShortestPathAlgorithm<int, Edge<int>>.UnaryWeightsFromEdgeList(g);
DijkstraShortestPathAlgorithm<int, Edge<int>> dij = new DijkstraShortestPathAlgorithm<int, Edge<int>>(g, weights);
VertexPredecessorRecorderObserver<int, Edge<int>> vis = new VertexPredecessorRecorderObserver<int, Edge<int>>();
vis.Attach(dij);
dij.Compute(1);
IList<Edge<int>> col = vis.Path(2);
Assert.AreEqual(1, col.Count);
Assert.AreEqual(e12, col[0]);
col = vis.Path(3);
Assert.AreEqual(2, col.Count);
Assert.AreEqual(e12, col[0]);
Assert.AreEqual(e23, col[1]);
}
示例9: CheckPredecessorDoubleLineGraph
public void CheckPredecessorDoubleLineGraph()
{
AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
g.AddVertex(1);
g.AddVertex(2);
g.AddVertex(3);
Edge<int> e12 = new Edge<int>(1, 2); g.AddEdge(e12);
Edge<int> e23 = new Edge<int>(2, 3); g.AddEdge(e23);
Edge<int> e13 = new Edge<int>(1, 3); g.AddEdge(e13);
var dij = new DijkstraShortestPathAlgorithm<int, Edge<int>>(g, e => 1);
var vis = new VertexPredecessorRecorderObserver<int, Edge<int>>();
using(vis.Attach(dij))
dij.Compute(1);
IEnumerable<Edge<int>> path;
Assert.IsTrue(vis.TryGetPath(2, out path));
var col = path.ToList();
Assert.AreEqual(1, col.Count);
Assert.AreEqual(e12, col[0]);
Assert.IsTrue(vis.TryGetPath(3, out path));
col = path.ToList();
Assert.AreEqual(1, col.Count);
Assert.AreEqual(e13, col[0]);
}
示例10: FileDependency
public void FileDependency()
{
AdjacencyGraph<string, Edge<string>> g = new AdjacencyGraph<string, Edge<string>>();
GraphFactory.FileDependency(g);
this.Compute(g);
this.ComputeCriticalPath(g);
}
示例11: GenerateDotFile
public void GenerateDotFile()
{
var graph = new AdjacencyGraph<string, TaggedEdge<string, string>>();
for (int i = 0; i < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); i++)
{
graph.AddVertex(String.Format("{0}", i));
}
for (int i = 0; i < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); i++)
{
for (int j = 0; j < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); j++)
{
if ((m_Matrix[i, j] == true) & (i < j))
{
graph.AddEdge(new TaggedEdge<string, string>(String.Format("{0}", i), String.Format("{0}", j), String.Format("{0}", i)));
}
}
}
var graphViz = new GraphvizAlgorithm<string, TaggedEdge<string, string>>(graph, @".\", QuickGraph.Graphviz.Dot.GraphvizImageType.Png);
graphViz.FormatVertex += (sender, e) =>
{
e.VertexFormatter.Shape = QuickGraph.Graphviz.Dot.GraphvizVertexShape.Circle;
};
graphViz.FormatEdge += (sender, e) =>
{
e.EdgeFormatter.Dir = QuickGraph.Graphviz.Dot.GraphvizEdgeDirection.None;
};
graphViz.Generate(new FileDotEngine(), m_Name);
}
示例12: Removing_Explicit_Edges_2
public void Removing_Explicit_Edges_2()
{
var graph = new AdjacencyGraph<int, Edge<int>>();
graph.AddVertex(1);
graph.AddVertex(2);
graph.AddVertex(3);
graph.AddVertex(4);
graph.AddVertex(5);
graph.AddVertex(6);
graph.AddVertex(7);
graph.AddEdge(new Edge<int>(1, 3));
graph.AddEdge(new Edge<int>(1, 4));
graph.AddEdge(new Edge<int>(1, 6));
graph.AddEdge(new Edge<int>(3, 6));
graph.AddEdge(new Edge<int>(4, 6));
graph.AddEdge(new Edge<int>(2, 4));
graph.AddEdge(new Edge<int>(2, 5));
graph.AddEdge(new Edge<int>(2, 7));
graph.AddEdge(new Edge<int>(4, 7));
graph.AddEdge(new Edge<int>(5, 7));
GraphHelper.RemoveExplicitEdges(graph);
Assert.AreEqual(8, graph.EdgeCount);
Assert.IsTrue(graph.ContainsEdge(1, 3));
Assert.IsTrue(graph.ContainsEdge(1, 4));
Assert.IsTrue(graph.ContainsEdge(2, 4));
Assert.IsTrue(graph.ContainsEdge(2, 5));
Assert.IsTrue(graph.ContainsEdge(3, 6));
Assert.IsTrue(graph.ContainsEdge(4, 6));
Assert.IsTrue(graph.ContainsEdge(4, 7));
Assert.IsTrue(graph.ContainsEdge(5, 7));
}
示例13: QGPathFinder
public QGPathFinder(FloorPlan floorPlan)
{
this.messages += "- Checking Floor Plan...\n";
graph = new AdjacencyGraph<string, Edge<string>>(true);
edgeCost = new Dictionary<Edge<string>, double>(graph.EdgeCount);
this.fp = floorPlan;
if (this.fp.getStartTile() != null)
{
this.messages += " Start Point is OK...\n";
startPoint = this.fp.getStartTile().Position.X + "_" + this.fp.getStartTile().Position.Y;
}
else
{
this.messages += " Start Point is not valid...\n";
startPoint = "4_4";
}
if (this.fp.getTargetTile() != null)
{
this.messages += " Target Point is OK...\n";
targetPoint = this.fp.getTargetTile().Position.X + "_" + this.fp.getTargetTile().Position.Y;
}
else
{
this.messages += " Target Point is not valid...\n";
targetPoint = "4_6";
}
buildGraph();
}
示例14: RouteFinder
public RouteFinder(IGameDataProvider gameDataProvider)
{
provider = gameDataProvider;
logger = LogManager.GetCurrentClassLogger();
graph = new AdjacencyGraph<StarSystem, Edge<StarSystem>>();
weights = new Dictionary<Edge<StarSystem>, double>();
}
示例15: Render
public override void Render(Context context, TextWriter result)
{
// init modules context
ModulesContext modules = DotLiquidModules.ContextExtractor.GetOrAddModulesContext(context);
// allow module name to be supplied as a variable, makes sense when you supply modules in the Model
object evalName = context[_moduleName];
string modName = evalName != null ? Convert.ToString(evalName) : _moduleName;
// remember modules that were already loaded
Dictionary<string, bool> alreadyLoaded = new Dictionary<string, bool>();
foreach (string moduleName in modules.ModuleIndex.Keys)
{
alreadyLoaded[moduleName] = true;
}
// add module to context, get its dependencies in graph
AdjacencyGraph<Module, Edge<Module>> dependencyGraph = new AdjacencyGraph<Module, Edge<Module>>(true);
AddModuleToContextByName(modName, modules, context, dependencyGraph);
// add dependency tree into context's dependency list
foreach (Module module in dependencyGraph.TopologicalSort())
{
if (!alreadyLoaded.ContainsKey(module.ModuleName))
{
modules.DependencyOrder.Add(module);
}
}
}