本文整理汇总了C#中Graph.V方法的典型用法代码示例。如果您正苦于以下问题:C# Graph.V方法的具体用法?C# Graph.V怎么用?C# Graph.V使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph.V方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DepthFirstSearchTest
public void DepthFirstSearchTest()
{
string[] graphEdges = new[] {
"0 5",
"2 4",
"2 3",
"1 2",
"0 1",
"3 4",
"3 5",
"0 2"};
var graph = new Graph(6, 8, graphEdges);
DepthFirstSearch search = new DepthFirstSearch(graph, 0);
for (int v = 0; v < graph.V(); v++)
{
if (search.Marked(v))
{
Console.WriteLine(v + " ");
}
}
Console.WriteLine();
bool isCohesion = true;
if (search.Count() != graph.V())
{
isCohesion = false;
}
Assert.AreEqual(true, isCohesion);
}
示例2: BreadthFirstPaths
public BreadthFirstPaths(Graph graph, int s)
{
marked = new bool[graph.V()];
edgeTo = new int[graph.V()];
this.s = s;
bfs(graph, s);
}
示例3: DepthFirstPath
public DepthFirstPath(Graph g, int s)
{
marked = new bool[g.V()];
edgeTo = new int[g.V()];
this.s = s;
dfs(g, s);
}
示例4: CC
public CC(Graph g)
{
marked = new bool[g.V()];
id = new int[g.V()];
for (int s = 0; s < g.V(); s++)
{
if (!marked[s])
{
dfs(g, s);
count++;
}
}
}
示例5: DepthFirstPathTest
public void DepthFirstPathTest()
{
string[] graphEdges = new[] {
"0 5",
"2 4",
"2 3",
"1 2",
"0 1",
"3 4",
"3 5",
"0 2"};
var graph = new Graph(6, 8, graphEdges);
DepthFirstPath search = new DepthFirstPath(graph, 0);
var pathBuilder = new StringBuilder();
for (int v = 0; v < graph.V(); v++)
{
if (search.HasPathTo(v))
{
foreach (int x in search.PathTo(v))
{
if (x == 0)
pathBuilder.Append(x);
else
{
pathBuilder.Append(" - " + x);
}
}
}
}
}
示例6: CCTest
public void CCTest()
{
string[] graphEdges = new[] {
"0 5",
"4 3",
"0 1",
"9 12",
"6 4",
"5 4",
"0 2",
"11 12",
"9 10",
"0 6",
"7 8",
"9 11",
"5 3"};
var graph = new Graph(13, 13, graphEdges);
CC cc = new CC(graph);
int m = cc.Count();
List<int>[] components = new List<int>[m];
for (int i = 0; i < m; i++)
{
components[i] = new List<int>();
}
for (int v = 0; v < graph.V(); v++)
{
components[cc.Id(v)].Add(v);
}
StringBuilder builder = new StringBuilder();
for (int i = 0; i < m; i++)
{
foreach (int v in components[i])
{
builder.Append(v + " ");
}
builder.AppendLine();
}
}
示例7: DepthFirstSearch
public DepthFirstSearch(Graph g, int s)
{
marked = new bool[g.V()];
dfs(g, s);
}