Skip to content

Commit

Permalink
Some code cleaning and Javadoc making
Browse files Browse the repository at this point in the history
  • Loading branch information
infovillasimius committed Mar 13, 2019
1 parent 93b31e2 commit b52c97b
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 32 deletions.
46 changes: 46 additions & 0 deletions NetworkFlowsOptimization/src/NetworkFlowOptimization/Arc.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public class Arc implements Comparable<Arc> {
Node tail; //nodo coda
Node head; //nodo testa

/**
* New Arc
* @param cost int Arc cost
* @param tail Node Arc tail
* @param head Node Arc head
*/
public Arc(int cost, Node tail, Node head) {
this.capacity = 0;
this.minFlow = 0;
Expand All @@ -43,6 +49,13 @@ public Arc(int cost, Node tail, Node head) {
this.head = head;
}

/**
* New Arc
* @param cost int (Arc cost)
* @param tail Node (Arc tail)
* @param head Node (Arc head)
* @param capacity int (Arc capacity)
*/
public Arc(int cost, Node tail, Node head, int capacity) {
this.capacity = capacity;
this.minFlow = 0;
Expand All @@ -54,6 +67,11 @@ public Arc(int cost, Node tail, Node head, int capacity) {
this.head = head;
}

/**
* New Arc
* @param tail Node (Arc tail)
* @param head Node (Arc head)
*/
public Arc(Node tail, Node head) {
this.capacity = 0;
this.minFlow = 0;
Expand All @@ -65,14 +83,26 @@ public Arc(Node tail, Node head) {
this.head = head;
}

/**
* Arc to String for MaxFlow Problem
* @return String
*/
public String toFlow() {
return "(" + tail.number + ", " + head.number + ") => flow=" + flow + ", capacity=" + capacity + "\n";
}

/**
* Arc to String for MinCostFlow Problem results
* @return String
*/
public String toMinCostFlow() {
return "(" + tail.number + ", " + head.number + ") => flow=" + flow + ", cost per unit=" + cost + ", capacity=" + capacity + "\n";
}

/**
* Arc to String for MinCostFlow Problem initial graph
* @return String
*/
public String toEmptyMinCostFlow() {
return "(" + tail.number + ", " + head.number + ") => cost per unit=" + cost + ", capacity=" + capacity + "\n";
}
Expand All @@ -87,18 +117,34 @@ public int compareTo(Arc o) {
return (this.tail.number - o.tail.number) * 1000000 + (this.head.number - o.head.number);
}

/**
* Get arc cost
* @return int (Arc cost)
*/
public int getCost() {
return cost;
}

/**
* Get arc tail
* @return Node (Arc tail)
*/
public Node getTail() {
return tail;
}

/**
* Get arc head
* @return Node (Arc head)
*/
public Node getHead() {
return head;
}

/**
* Set arc flow and update residual capacities
* @param flow Flow to set
*/
public void setFlow(int flow) {
if (flow < 0) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public CircularQueue(int n) {
}

/**
*
* Store a new element
* @param n The element to store
* @param d The key of the element (distance)
*/
Expand All @@ -58,7 +58,7 @@ public void store(E n, int d) {

/**
* Get the next element in the queue
* @return the next element in the queue
* @return E (the next element in the queue)
*/
public E next() {

Expand Down
Loading

0 comments on commit b52c97b

Please sign in to comment.