Skip to content

Commit 4d1f5cc

Browse files
committed
Reverting to previous version.
1 parent 3b15130 commit 4d1f5cc

2 files changed

Lines changed: 19 additions & 27 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
/Test_Numerics/bin
2727
/Test_Numerics/obj
2828
/Numerics/.vs/Numerics
29+
/Numerics/.vs

4.8.1/Numerics/Mathematics/Optimization/Dynamic/Network.cs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,55 +41,46 @@ namespace Numerics.Mathematics.Optimization
4141
/// </summary>
4242
public class Network
4343
{
44-
private readonly Dictionary<int, List<Edge>> _outgoingEdges;
45-
private readonly Dictionary<int, List<Edge>> _incomingEdges;
44+
private readonly List<Edge>[] _outgoingEdges;
45+
private readonly List<Edge>[] _incomingEdges;
4646
private readonly int _nodeCount;
4747
private readonly int[] _destinationIndices;
48+
//private readonly RoadSegment[] _segments;
4849
private readonly Edge[] _edges;
4950

51+
//public RoadSegment[] Segments { get => _segments; }
5052
public int[] DestinationIndices { get => _destinationIndices; }
51-
public Dictionary<int,List<Edge>> IncomingEdges { get => _incomingEdges; }
52-
public Dictionary<int, List<Edge>> OutgoingEdges { get => _outgoingEdges; }
5353

54-
public Network(Edge[] edges, int[] destinationIndices, int nodeCount = -1)
54+
public List<Edge>[] IncomingEdges { get => _incomingEdges; }
55+
public List<Edge>[] OutgoingEdges { get => _outgoingEdges; }
56+
57+
public Network(Edge[] edges, int[] destinationIndices)
5558
{
56-
_edges = edges;
59+
//_segments = roadSegments;
60+
_edges = edges;//new Edge[edges.Length];
5761
_destinationIndices = destinationIndices;
58-
59-
60-
if (nodeCount != -1)
61-
{
62-
_nodeCount = nodeCount;
63-
}
64-
else
65-
{
66-
_nodeCount = 0;
67-
// Calculate the number of unique nodes
68-
}
69-
62+
_nodeCount = 0;
7063

7164
//for (int i = 0; i < roadSegments.Length; i++)
7265
//{
7366
// _edges[i] = new Edge(roadSegments[i].HeadIndex, roadSegments[i].TailIndex, (float)roadSegments[i].Source.TravelTimeSeconds, i);
7467
// if (_edges[i].FromIndex > _nodeCount) { _nodeCount = _edges[i].FromIndex; }
7568
// if (_edges[i].ToIndex > _nodeCount) { _nodeCount = _edges[i].ToIndex; }
7669
//}
77-
//var max1 = edges.Select(x=>x.FromIndex).Max();
78-
//var max2 = edges.Select(x => x.ToIndex).Max();
79-
//var max = Math.Max(max1, max2);
70+
var max1 = edges.Select(x => x.FromIndex).Max();
71+
var max2 = edges.Select(x => x.ToIndex).Max();
72+
var max = Math.Max(max1, max2);
8073
//// Add one to the count for the index offset.
8174
//_nodeCount += 1;
82-
_incomingEdges = new Dictionary<int, List<Edge>>();
83-
_outgoingEdges = new Dictionary<int, List<Edge>>();
75+
_incomingEdges = new List<Edge>[max];
76+
_outgoingEdges = new List<Edge>[max];
8477
//
8578
for (int i = 0; i < _edges.Length; i++)
8679
{
87-
if(_incomingEdges.ContainsKey(_edges[i].ToIndex)==false) { _incomingEdges.Add(_edges[i].ToIndex, new List<Edge>()); }
88-
//if (_incomingEdges[_edges[i].ToIndex] == null) { _incomingEdges[_edges[i].ToIndex] = new List<Edge>(); }
80+
if (_incomingEdges[_edges[i].ToIndex] == null) { _incomingEdges[_edges[i].ToIndex] = new List<Edge>(); }
8981
_incomingEdges[_edges[i].ToIndex].Add(_edges[i]);
9082

91-
if (_outgoingEdges.ContainsKey(_edges[i].FromIndex) == false) { _outgoingEdges.Add(_edges[i].FromIndex, new List<Edge>()); }
92-
//if (_outgoingEdges[_edges[i].FromIndex] == null) { _outgoingEdges[_edges[i].FromIndex] = new List<Edge>(); }
83+
if (_outgoingEdges[_edges[i].FromIndex] == null) { _outgoingEdges[_edges[i].FromIndex] = new List<Edge>(); }
9384
_outgoingEdges[_edges[i].FromIndex].Add(_edges[i]);
9485
}
9586

0 commit comments

Comments
 (0)