示例#1
0
        public EdgeData WithWeight(double weight)
        {
            EdgeData result = Clone();

            result.weight = weight;
            return(result);
        }
示例#2
0
        public EdgeData WithData(IEdgeData data)
        {
            EdgeData result = Clone();

            result.data = data;
            return(result);
        }
示例#3
0
        public EdgeData WithColor(Color color)
        {
            EdgeData result = Clone();

            result.color = color;
            return(result);
        }
示例#4
0
        internal override void UpdateEdgeData(AdjMatrixGraphVertex <T> vertex1, AdjMatrixGraphVertex <T> vertex2, Func <EdgeData, EdgeData> updateFunc)
        {
            EdgeData edgeData = updateFunc(GetEdgeDataCore(vertex1, vertex2));

            Matrix[vertex1.Handle, vertex2.Handle] = edgeData;
            Matrix[vertex2.Handle, vertex1.Handle] = edgeData;
        }
        internal override void UpdateEdgeData(BipartiteGraphVertex <T> vertex1, BipartiteGraphVertex <T> vertex2, Func <EdgeData, EdgeData> updateFunc)
        {
            var      uVertex  = GetUVertex(vertex1, vertex2);
            var      vVertex  = GetVVertex(vertex1, vertex2);
            EdgeData edgeData = updateFunc(GetEdgeDataCore(vertex1, vertex2));

            Matrix[vVertex.Handle, uVertex.Handle] = edgeData;
        }
示例#6
0
 internal void OnEdgeDeleted(EdgeData edgeData)
 {
     EdgeProperties.Count--;
     if (edgeData.IsWeighed)
     {
         EdgeProperties.WCount--;
     }
     if (edgeData.IsNegativeWeighed)
     {
         EdgeProperties.NCount--;
     }
 }
示例#7
0
 internal void OnEdgeAdded(EdgeData edgeData)
 {
     EdgeProperties.Count++;
     if (edgeData.IsWeighed)
     {
         EdgeProperties.WCount++;
     }
     if (edgeData.IsNegativeWeighed)
     {
         EdgeProperties.NCount++;
     }
 }
        public void DeleteEdge(BipartiteGraphVertex <T> vertex1, BipartiteGraphVertex <T> vertex2)
        {
            Guard.IsNotNull(vertex1, nameof(vertex1));
            Guard.IsNotNull(vertex2, nameof(vertex2));
            CheckVertexOwner(vertex1);
            CheckVertexOwner(vertex2);
            if (!Data.AreVerticesAdjacent(vertex1, vertex2))
            {
                throw new InvalidOperationException();
            }
            EdgeData edgeData = Data.GetEdgeData(vertex1, vertex2);

            Data.DeleteEdge(vertex1, vertex2);
            vertex1.Degree--;
            vertex2.Degree--;
            Properties.OnEdgeDeleted(edgeData);
        }
        internal TGraph CloneWithEdges <TGraph>(TGraph graph) where TGraph : BipartiteGraph <T>, new()
        {
            Guard.IsNotNull(graph, nameof(graph));
            if (Data.GetUSize() != graph.Data.GetUSize() || Data.GetVSize() != graph.Data.GetVSize())
            {
                throw new InvalidOperationException();
            }
            TGraph result = Clone <TGraph>(false);

            foreach (var edge in graph.GetEdgeList())
            {
                int uVertexHandle = edge.StartVertex.Handle;
                var vVertexHandle = edge.EndVertex.Handle;
                if (!AreVerticesAdjacent(uVertexHandle, vVertexHandle))
                {
                    throw new InvalidOperationException();
                }
                EdgeData edgeData = GetEdgeData(uVertexHandle, vVertexHandle);
                result.CreateEdge(uVertexHandle, vVertexHandle, edgeData.Weight);
            }
            return(result);
        }
        bool IsMatchedEdge(BipartiteGraphVertex <T> vertex1, BipartiteGraphVertex <T> vertex2)
        {
            EdgeData edgeData = Data.GetEdgeData(vertex1, vertex2);

            return(edgeData.IsDataOfType <GetMaximalMatchingMatchedData>());
        }
示例#11
0
 static bool Equals(EdgeData x, EdgeData y)
 {
     return(x.Initialized == y.Initialized && MathUtils.AreEqual(x.Weight, y.Weight) && x.Color.Equals(y.Color) && ReferenceEquals(x.Data, y.Data));
 }
示例#12
0
        public override bool Equals(object obj)
        {
            EdgeData other = (EdgeData)obj;

            return(Equals(this, other));
        }