本文整理汇总了C#中IGraph.SetInternallyVisited方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.SetInternallyVisited方法的具体用法?C# IGraph.SetInternallyVisited怎么用?C# IGraph.SetInternallyVisited使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraph
的用法示例。
在下文中一共展示了IGraph.SetInternallyVisited方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReachableEdgesOutgoing
public static Dictionary<IEdge, SetValueType> ReachableEdgesOutgoing(IGraph graph, INode startNode, EdgeType outgoingEdgeType, NodeType targetNodeType, IActionExecutionEnvironment actionEnv, int threadId)
{
Dictionary<IEdge, SetValueType> outgoingEdgesSet = new Dictionary<IEdge, SetValueType>();
ReachableEdgesOutgoing(startNode, outgoingEdgeType, targetNodeType, outgoingEdgesSet, graph, actionEnv, threadId);
foreach(KeyValuePair<IEdge, SetValueType> kvp in outgoingEdgesSet)
{
IEdge edge = kvp.Key;
graph.SetInternallyVisited(edge.Source, false, threadId);
graph.SetInternallyVisited(edge.Target, false, threadId);
}
return outgoingEdgesSet;
}
示例2: ReachableEdges
/// <summary>
/// Fills set of edges reachable from the start node, under the type constraints given, in a depth-first walk
/// </summary>
private static void ReachableEdges(INode startNode, EdgeType incidentEdgeType, NodeType adjacentNodeType, Dictionary<IEdge, SetValueType> incidentEdgesSet, IGraph graph, int threadId)
{
foreach(IEdge edge in startNode.GetCompatibleOutgoing(incidentEdgeType))
{
INode adjacentNode = edge.Target;
if(!adjacentNode.InstanceOf(adjacentNodeType))
continue;
incidentEdgesSet[edge] = null;
if(graph.IsInternallyVisited(adjacentNode, threadId))
continue;
graph.SetInternallyVisited(adjacentNode, true, threadId);
ReachableEdges(adjacentNode, incidentEdgeType, adjacentNodeType, incidentEdgesSet, graph, threadId);
}
foreach(IEdge edge in startNode.GetCompatibleIncoming(incidentEdgeType))
{
INode adjacentNode = edge.Source;
if(!adjacentNode.InstanceOf(adjacentNodeType))
continue;
incidentEdgesSet[edge] = null;
if(graph.IsInternallyVisited(adjacentNode, threadId))
continue;
graph.SetInternallyVisited(adjacentNode, true, threadId);
ReachableEdges(adjacentNode, incidentEdgeType, adjacentNodeType, incidentEdgesSet, graph, threadId);
}
}
示例3: CountAdjacentIncoming
public static int CountAdjacentIncoming(IGraph graph, INode startNode, EdgeType incidentEdgeType, NodeType adjacentNodeType, IActionExecutionEnvironment actionEnv, int threadId)
{
int count = 0;
foreach(IEdge edge in startNode.Incoming)
{
++actionEnv.PerformanceInfo.SearchStepsPerThread[threadId];
if(!edge.InstanceOf(incidentEdgeType))
continue;
INode adjacentNode = edge.Source;
if(!adjacentNode.InstanceOf(adjacentNodeType))
continue;
if(graph.IsInternallyVisited(adjacentNode, threadId))
continue;
graph.SetInternallyVisited(adjacentNode, true, threadId);
++count;
}
foreach(IEdge edge in startNode.GetCompatibleIncoming(incidentEdgeType))
{
INode adjacentNode = edge.Source;
if(!adjacentNode.InstanceOf(adjacentNodeType))
continue;
graph.SetInternallyVisited(adjacentNode, false, threadId);
}
return count;
}
示例4: IsReachableEdgesIncoming
private static bool IsReachableEdgesIncoming(INode startNode, IEdge endEdge, EdgeType incomingEdgeType, NodeType sourceNodeType, IGraph graph, List<IGraphElement> visitedElems, IActionExecutionEnvironment actionEnv, int threadId)
{
bool result = false;
foreach(IEdge edge in startNode.Incoming)
{
++actionEnv.PerformanceInfo.SearchStepsPerThread[threadId];
if(!edge.InstanceOf(incomingEdgeType))
continue;
INode adjacentNode = edge.Source;
if(!adjacentNode.InstanceOf(sourceNodeType))
continue;
if(graph.IsInternallyVisited(edge, threadId))
continue;
graph.SetInternallyVisited(edge, true, threadId);
visitedElems.Add(edge);
if(edge.Source == endEdge)
return true;
if(graph.IsInternallyVisited(adjacentNode, threadId))
continue;
graph.SetInternallyVisited(adjacentNode, true, threadId);
visitedElems.Add(adjacentNode);
result = IsReachableEdgesIncoming(adjacentNode, endEdge, incomingEdgeType, sourceNodeType, graph, visitedElems, actionEnv, threadId);
if(result == true)
break;
}
return result;
}
示例5: IsReachableIncoming
/// <summary>
/// Returns whether the end node is reachable from the start node, via incoming edges, under the type constraints given
/// </summary>
public static bool IsReachableIncoming(IGraph graph, INode startNode, INode endNode, EdgeType incomingEdgeType, NodeType sourceNodeType, int threadId)
{
List<INode> visitedNodes = new List<INode>((int)Math.Sqrt(graph.NumNodes));
bool result = IsReachableIncoming(startNode, endNode, incomingEdgeType, sourceNodeType, graph, visitedNodes, threadId);
for(int i = 0; i < visitedNodes.Count; ++i)
graph.SetInternallyVisited(visitedNodes[i], false, threadId);
return result;
}
示例6: IsReachableEdgesOutgoing
/// <summary>
/// Returns whether the end edge is reachable from the start node, via outgoing edges, under the type constraints given
/// </summary>
public static bool IsReachableEdgesOutgoing(IGraph graph, INode startNode, IEdge endEdge, EdgeType outgoingEdgeType, NodeType targetNodeType, int threadId)
{
List<IGraphElement> visitedElems = new List<IGraphElement>((int)Math.Sqrt(graph.NumNodes));
bool result = IsReachableEdgesOutgoing(startNode, endEdge, outgoingEdgeType, targetNodeType, graph, visitedElems, threadId);
for(int i = 0; i < visitedElems.Count; ++i)
graph.SetInternallyVisited(visitedElems[i], false, threadId);
return result;
}
示例7: IsReachableOutgoing
private static bool IsReachableOutgoing(INode startNode, INode endNode, EdgeType outgoingEdgeType, NodeType targetNodeType, IGraph graph, List<INode> visitedNodes, IActionExecutionEnvironment actionEnv, int threadId)
{
bool result = false;
foreach(IEdge edge in startNode.Outgoing)
{
++actionEnv.PerformanceInfo.SearchStepsPerThread[threadId];
if(!edge.InstanceOf(outgoingEdgeType))
continue;
INode adjacentNode = edge.Target;
if(!adjacentNode.InstanceOf(targetNodeType))
continue;
if(graph.IsInternallyVisited(adjacentNode, threadId))
continue;
if(edge.Target == endNode)
return true;
graph.SetInternallyVisited(adjacentNode, true, threadId);
visitedNodes.Add(adjacentNode);
result = IsReachableOutgoing(adjacentNode, endNode, outgoingEdgeType, targetNodeType, graph, visitedNodes, actionEnv, threadId);
if(result == true)
break;
}
return result;
}
示例8: CountReachableEdgesIncoming
public static int CountReachableEdgesIncoming(IGraph graph, INode startNode, EdgeType incomingEdgeType, NodeType sourceNodeType, IActionExecutionEnvironment actionEnv, int threadId)
{
// todo: more performant implementation with internally visited used for marking and list for unmarking instead of hash set
Dictionary<IEdge, SetValueType> incomingEdgesSet = new Dictionary<IEdge, SetValueType>();
ReachableEdgesIncoming(startNode, incomingEdgeType, sourceNodeType, incomingEdgesSet, graph, actionEnv, threadId);
foreach(KeyValuePair<IEdge, SetValueType> kvp in incomingEdgesSet)
{
IEdge edge = kvp.Key;
graph.SetInternallyVisited(edge.Source, false);
graph.SetInternallyVisited(edge.Target, false);
}
return incomingEdgesSet.Count;
}