public static string ArcToString(this IArcLookup graph, Arc arc) { if (arc == Arc.Invalid) { return("Arc.Invalid"); } return(graph.U(arc) + ((!graph.IsEdge(arc)) ? "--->" : "<-->") + graph.V(arc)); }
public static Node Other(this IArcLookup graph, Arc arc, Node node) { Node node2 = graph.U(arc); if (node2 != node) { return(node2); } return(graph.V(arc)); }
/// Returns the two nodes of an arc. /// \param arc An arc belonging to the graph. /// \param allowDuplicates /// - If \c true, then the resulting array always contains two items, even if the arc connects a node with itself. /// - If \c false, then the resulting array contains only one node if the arc is a loop. public static Node[] Nodes(this IArcLookup graph, Arc arc, bool allowDuplicates = true) { var u = graph.U(arc); var v = graph.V(arc); if (!allowDuplicates && u == v) { return new Node[] { u } } ; return(new Node[] { u, v }); } }
public static Node[] Nodes(this IArcLookup graph, Arc arc, bool allowDuplicates = true) { Node node = graph.U(arc); Node node2 = graph.V(arc); if (!allowDuplicates && node == node2) { return(new Node[1] { node }); } return(new Node[2] { node, node2 }); }