@@ -21,13 +21,13 @@ public class DirectedWeightedDenseGraph<T> : DirectedDenseGraph<T>, IWeightedGra
21
21
/// <summary>
22
22
/// INSTANCE VARIABLES
23
23
/// </summary>
24
- private const int EMPTY_EDGE_SLOT = 0 ;
24
+ private const long EMPTY_EDGE_SLOT = 0 ;
25
25
private const object EMPTY_VERTEX_SLOT = ( object ) null ;
26
26
27
27
// Store edges and their weights as integers.
28
28
// Any edge with a value of zero means it doesn't exist. Otherwise, it exist with a specific weight value.
29
29
// Default value for positive edges is 1.
30
- protected new int [ , ] _adjacencyMatrix { get ; set ; }
30
+ protected new long [ , ] _adjacencyMatrix { get ; set ; }
31
31
32
32
33
33
/// <summary>
@@ -40,7 +40,7 @@ public DirectedWeightedDenseGraph(uint capacity = 10)
40
40
_verticesCapacity = ( int ) capacity ;
41
41
42
42
_vertices = new ArrayList < object > ( _verticesCapacity ) ;
43
- _adjacencyMatrix = new int [ _verticesCapacity , _verticesCapacity ] ;
43
+ _adjacencyMatrix = new long [ _verticesCapacity , _verticesCapacity ] ;
44
44
_adjacencyMatrix . Populate ( rows : _verticesCapacity , columns : _verticesCapacity , defaultValue : EMPTY_EDGE_SLOT ) ;
45
45
}
46
46
@@ -56,7 +56,7 @@ protected override bool _doesEdgeExist(int source, int destination)
56
56
/// <summary>
57
57
/// Helper function. Gets the weight of a directed edge.
58
58
/// </summary>
59
- private int _getEdgeWeight ( int source , int destination )
59
+ private long _getEdgeWeight ( int source , int destination )
60
60
{
61
61
return _adjacencyMatrix [ source , destination ] ;
62
62
}
@@ -95,7 +95,7 @@ public virtual IEnumerable<WeightedEdge<T>> Edges
95
95
/// <summary>
96
96
/// Connects two vertices together with a weight, in the direction: first->second.
97
97
/// </summary>
98
- public virtual bool AddEdge ( T source , T destination , int weight )
98
+ public virtual bool AddEdge ( T source , T destination , long weight )
99
99
{
100
100
// Return if the weight is equals to the empty edge value
101
101
if ( weight == EMPTY_EDGE_SLOT )
@@ -145,7 +145,7 @@ public override bool RemoveEdge(T source, T destination)
145
145
/// <summary>
146
146
/// Updates the edge weight from source to destination.
147
147
/// </summary>
148
- public virtual bool UpdateEdgeWeight ( T source , T destination , int weight )
148
+ public virtual bool UpdateEdgeWeight ( T source , T destination , long weight )
149
149
{
150
150
// Return if the weight is equals to the empty edge value
151
151
if ( weight == EMPTY_EDGE_SLOT )
@@ -235,20 +235,20 @@ public virtual WeightedEdge<T> GetEdge(T source, T destination)
235
235
/// <summary>
236
236
/// Returns the edge weight from source to destination.
237
237
/// </summary>
238
- public virtual int GetEdgeWeight ( T source , T destination )
238
+ public virtual long GetEdgeWeight ( T source , T destination )
239
239
{
240
240
return GetEdge ( source , destination ) . Weight ;
241
241
}
242
242
243
243
/// <summary>
244
244
/// Returns the neighbours of a vertex as a dictionary of nodes-to-weights.
245
245
/// </summary>
246
- public virtual Dictionary < T , int > NeighboursMap ( T vertex )
246
+ public virtual Dictionary < T , long > NeighboursMap ( T vertex )
247
247
{
248
248
if ( ! HasVertex ( vertex ) )
249
249
return null ;
250
250
251
- var neighbors = new Dictionary < T , int > ( ) ;
251
+ var neighbors = new Dictionary < T , long > ( ) ;
252
252
int source = _vertices . IndexOf ( vertex ) ;
253
253
254
254
// Check existence of vertex
@@ -328,7 +328,7 @@ public override void Clear()
328
328
_edgesCount = 0 ;
329
329
_verticesCount = 0 ;
330
330
_vertices = new ArrayList < object > ( _verticesCapacity ) ;
331
- _adjacencyMatrix = new int [ _verticesCapacity , _verticesCapacity ] ;
331
+ _adjacencyMatrix = new long [ _verticesCapacity , _verticesCapacity ] ;
332
332
_adjacencyMatrix . Populate ( rows : _verticesCapacity , columns : _verticesCapacity , defaultValue : EMPTY_EDGE_SLOT ) ;
333
333
}
334
334
0 commit comments