tbf/SchematicDrawing/GNode.cs

53 lines
1.2 KiB
C#
Raw Normal View History

///
/// Copyright (c) 2020 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
namespace SchematicDrawing
{
public class GNode
{
/// Graph node properties
public IDrawingItem Item;
public int NodeId;
public readonly IList<GEdge> Edges;
/// Distance from a start node
public int Dist;
/// Minimal heap index
public int HeapIx;
/// <summary>
/// Constructor
/// </summary>
/// <param name="item">Item</param>
/// <param name="nodeId"Node ID></param>
public GNode(IDrawingItem item, int nodeId)
{
Item = item;
NodeId = nodeId;
Edges = new List<GEdge>();
Dist = int.MaxValue;
}
public void AddEdge(GEdge edge)
{
Edges.Add(edge);
}
public GNode Reset(int heapIx, int dist = int.MaxValue)
{
HeapIx = heapIx;
Dist = dist;
return this;
}
public override string ToString()
{
return string.Format("{0}/{1} dist={2}", Item.Name, NodeId, Dist);
}
}
}