예제 #1
0
        public void removeEdgeIfTest()
        {
            var graph = new BidirectionalGraph <int, IEdge <int> >();

            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddEdge(new EquatableEdge <int>(1, 2));
            graph.AddEdge(new EquatableEdge <int>(2, 3));
            graph.AddEdge(new EquatableEdge <int>(2, 1));
            graph.RemoveOutEdgeIf(2, (edge) => edge.Target == 1);
            Assert.IsTrue(graph.ContainsEdge(1, 2));
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            Assert.IsTrue(graph.ContainsEdge(2, 3));
            graph.RemoveInEdgeIf(2, (edge) => edge.Source == 1);
            Assert.IsTrue(graph.ContainsEdge(2, 3));
            Assert.IsFalse(graph.ContainsEdge(1, 2));
        }
예제 #2
0
        /// <summary>
        /// Disconnects all connection to and from the given group.
        /// </summary>
        /// <param name="group">The ID of the group.</param>
        /// <returns>A task which indicates when the disconnection has taken place.</returns>
        public Task Disconnect(GroupCompositionId group)
        {
            {
                Debug.Assert(group != null, "The ID of the group should not be a null reference.");
            }

            m_Diagnostics.Log(
                LevelToLog.Trace,
                HostConstants.LogPrefix,
                string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.ProxyCompositionLayer_LogMessage_DisconnectingAllFromGroup_WithId,
                    group));

            var remoteTask = m_Commands.Disconnect(group);

            return(remoteTask.ContinueWith(
                       t =>
            {
                m_GroupConnections.RemoveInEdgeIf(group, edge => true);
                m_GroupConnections.RemoveOutEdgeIf(group, edge => true);
            }));
        }