public EdgeData WithWeight(double weight) { EdgeData result = Clone(); result.weight = weight; return(result); }
public EdgeData WithData(IEdgeData data) { EdgeData result = Clone(); result.data = data; return(result); }
public EdgeData WithColor(Color color) { EdgeData result = Clone(); result.color = color; return(result); }
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; }
internal void OnEdgeDeleted(EdgeData edgeData) { EdgeProperties.Count--; if (edgeData.IsWeighed) { EdgeProperties.WCount--; } if (edgeData.IsNegativeWeighed) { EdgeProperties.NCount--; } }
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>()); }
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)); }
public override bool Equals(object obj) { EdgeData other = (EdgeData)obj; return(Equals(this, other)); }