-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.cs
147 lines (129 loc) · 3.7 KB
/
Node.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Maximum_flow
{
/// <summary>
/// Class Node: represents a Node
/// </summary>
class Node
{
private string myname;
private bool mystart_node;
private bool myend_node;
private int myheight;
private List<Edge> myflow_in_list = new List<Edge>();
private List<Edge> myflow_out_list = new List<Edge>();
/// <summary>
/// Constructor
/// </summary>
/// <param name="name">Name of Node</param>
/// <param name="is_start_node">Is Node a start node?</param>
/// <param name="is_end_node">Is Node an end node?</param>
public Node(string name, bool is_start_node, bool is_end_node)
{
this.myname = name;
this.myheight = 0;
this.mystart_node = is_start_node;
this.myend_node = is_end_node;
}
/// <summary>
/// List of all Edges which flow in this Node
/// </summary>
/// <returns>List of flow in</returns>
public List<Edge> Flow_In_List()
{
return myflow_in_list;
}
/// <summary>
/// List of all Edges which flow out of this Node
/// </summary>
/// <returns>List of flow out</returns>
public List<Edge> Flow_Out_List()
{
return myflow_out_list;
}
public string Name
{
get
{
return myname;
}
set
{
myname = value;
}
}
public bool Is_Start()
{
return mystart_node;
}
public bool Is_End()
{
return myend_node;
}
/// <summary>
/// Adds an Edge which flows in this node
/// </summary>
/// <param name="flowin">Edge that flows in</param>
public void Add_Flow_In(Edge flowin)
{
myflow_in_list.Add(flowin);
}
/// <summary>
/// Adds an Edge which flows out of this node
/// </summary>
/// <param name="flowout">Edge that flows out</param>
public void Add_Flow_Out(Edge flowout)
{
myflow_out_list.Add(flowout);
}
/// <summary>
/// Removes an Edge which flows in this node
/// </summary>
/// <param name="flowin">Edge that flows in</param>
public void Remove_Flow_In(Edge flowin)
{
myflow_in_list.Remove(flowin);
}
/// <summary>
/// Removes an Edge which flows out of this node
/// </summary>
/// <param name="flowout">Edge that flows out</param>
public void Remove_Flow_Out(Edge flowout)
{
myflow_out_list.Remove(flowout);
}
public int Height
{
get
{
return myheight;
}
set
{
myheight = value;
}
}
public float Sum_Flow_In()
{
float sum = 0;
foreach (Edge edge in myflow_in_list)
{
sum += edge.Current_Flowrate;
}
return sum;
}
public float Sum_Flow_Out()
{
float sum = 0;
foreach (Edge edge in myflow_out_list)
{
sum += edge.Current_Flowrate;
}
return sum;
}
}
}