本文整理汇总了C#中AdjacencyGraph.AddVerticesAndEdgeRange方法的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph.AddVerticesAndEdgeRange方法的具体用法?C# AdjacencyGraph.AddVerticesAndEdgeRange怎么用?C# AdjacencyGraph.AddVerticesAndEdgeRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdjacencyGraph
的用法示例。
在下文中一共展示了AdjacencyGraph.AddVerticesAndEdgeRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGraphOfPipeSystem
private static IVertexAndEdgeListGraph<PipeGraphVertex, Edge<PipeGraphVertex>> CreateGraphOfPipeSystem(PipeGraphVertex firstVertex)
{
var graph = new AdjacencyGraph<PipeGraphVertex, Edge<PipeGraphVertex>>(false);
var verticesSeen = new HashSet<PipeGraphVertex>();
var verticesToCheck = new Stack<PipeGraphVertex>();
verticesToCheck.Push(firstVertex);
while (verticesToCheck.Any())
{
var vertexToCheck = verticesToCheck.Pop();
if (verticesSeen.Contains(vertexToCheck)) continue;
var sendsTo = GetVerticesYouSendMessagesTo(vertexToCheck);
var receivesFrom = GetVerticesYouReceiveMessagesFrom(vertexToCheck);
foreach (var vertex in sendsTo) verticesToCheck.Push(vertex);
foreach (var vertex in receivesFrom) verticesToCheck.Push(vertex);
graph.AddVertex(vertexToCheck);
graph.AddVerticesAndEdgeRange(sendsTo.Select(v => new Edge<PipeGraphVertex>(vertexToCheck, v)));
graph.AddVerticesAndEdgeRange(receivesFrom.Select(v => new Edge<PipeGraphVertex>(v, vertexToCheck)));
verticesSeen.Add(vertexToCheck);
}
return graph;
}
示例2: PerformNotifications
/// <summary>
/// Performs all notifications needed.
/// </summary>
private static void PerformNotifications()
{
var graph = new AdjacencyGraph<string, Edge<string>>();
foreach (string projectFolder in Directory.GetDirectories(Arguments.RootPath))
{
string projectName = Path.GetFileName(projectFolder);
string referencesDirectory = Path.Combine(projectFolder, Arguments.ReferencesFolderName);
graph.AddVerticesAndEdgeRange(
ReferenceMark.GetCurrent(ReferenceType.Internal, referencesDirectory)
.Select(referenceName => new Edge<string>(referenceName, projectName)));
graph.AddVerticesAndEdgeRange(
ReferenceMark.GetCurrent(ReferenceType.External, referencesDirectory)
.Select(referenceName => new Edge<string>(referenceName, projectName)));
}
GraphHelper.RemoveExplicitEdges(graph);
List<string> projectsToNotify = new List<string>();
IEnumerable<Edge<string>> outEdges;
if (graph.TryGetOutEdges(Arguments.ProjectName, out outEdges))
{
projectsToNotify.AddRange(outEdges.Select(edge => edge.Target));
}
string fileName = ReferenceMark.GetReferenceMarkName(Arguments.ProjectName);
foreach (string file in FindReferenceMarks(fileName))
{
string path = Path.GetDirectoryName(file);
path = Path.GetDirectoryName(path);
path = Path.GetDirectoryName(path);
string projectName = Path.GetFileName(path);
Console.WriteLine(
Resources.LogReferencedBy,
projectName);
if (projectsToNotify.Contains(projectName))
{
ReferenceMark.MarkUpdatedFile(file);
Console.WriteLine(
Resources.LogTriggeredBuild,
projectName);
}
}
}
示例3: 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;
}