public static UndirectedCyclicGraph <TKey> CreateNewFromFirstEdge(Node <TKey, UndirectedCyclicGraph <TKey> > firstNode, Node <TKey, UndirectedCyclicGraph <TKey> > secondNode)
        {
            var graph = new UndirectedCyclicGraph <TKey>();

            graph.AddEdgeWithNodes(firstNode, secondNode);
            return(graph);
        }
 public bool ConnectAnotherGraphToMe(UndirectedCyclicGraph <TKey> anotherGraph, Node <TKey, UndirectedCyclicGraph <TKey> > edgeFirstNode, Node <TKey, UndirectedCyclicGraph <TKey> > edgeSecondNode)
 {
     if (!CanCombineWith(anotherGraph, edgeFirstNode, edgeSecondNode))
     {
         return(false);
     }
     foreach (var node in anotherGraph.Nodes.Values)
     {
         AddNode(node);
     }
     return(anotherGraph.ClearNodes());
 }
        public static UndirectedCyclicGraph <TKey> CreateNewFromFirstEdge(Tuple <TKey, TKey> edge)
        {
            if (edge == null)
            {
                throw new ArgumentNullException(nameof(edge));
            }

            var graph = new UndirectedCyclicGraph <TKey>();

            graph.AddEdgeWithNodes(edge.Item1, edge.Item2);
            return(graph);
        }
 public bool CanCombineWith(UndirectedCyclicGraph <TKey> anotherGraph, Node <TKey, UndirectedCyclicGraph <TKey> > edgeFirstNode, Node <TKey, UndirectedCyclicGraph <TKey> > edgeSecondNode)
 {
     if (anotherGraph == null)
     {
         return(false);
     }
     if (anotherGraph.Equals(this))
     {
         return(false);
     }
     return((edgeFirstNode.GraphsThatIncludeThisNode.Contains(this) && edgeFirstNode.GraphsThatIncludeThisNode.Contains(anotherGraph)) ||
            (edgeSecondNode.GraphsThatIncludeThisNode.Contains(this) && edgeSecondNode.GraphsThatIncludeThisNode.Contains(anotherGraph)));
 }