Question: I am implementing a scalingFordFulkerson Algorithm, however i need help with this error and how to solve it when input a graph i should get
I am implementing a scalingFordFulkerson Algorithm, however i need help with this error and how to solve it when input a graph i should get the maxflow and the run time. java code
ResidualGrappBuilder.java code
import graphCode.Edge;
import graphCode.SimpleGraph;
import graphCode.Vertex;
import java.util.Iterator;
public class ResidualGraphBuilder
public static SimpleGraph buildSimpleGraph graph, Vertex source, Vertex sink, double scalingFactor
SimpleGraph residualGraph new SimpleGraph;
VertexAttributes sourceData new VertexAttributestrue;
source.setDatasourceData;
residualGraph.getVertexListaddsource;
for Iterator edgeIter source.getIncidentEdgeListiterator; edgeIter.hasNext;
Edge edge Edge edgeIter.next;
Vertex neighbor graph.oppositesource edge;
error is on this line
if isEligibleEdgeneighbor edge, scalingFactor
residualGraph.getEdgeListaddedge;
residualGraph.getVertexListaddneighbor;
if neighbor sink
return residualGraph;
SimpleGraph subGraph buildgraph neighbor, sink, scalingFactor;
if subGraphgetVertexListgetLast sink
return subGraph;
residualGraph.getEdgeListremoveLast;
residualGraph.getVertexListremoveLast;
return residualGraph;
private static boolean isEligibleEdgeVertex neighbor, Edge edge, double scalingFactor
VertexAttributes neighborData VertexAttributes neighbor.getData;
EdgeAttributes edgeAttributes EdgeAttributes edge.getData;
error in the line below
boolean notVisited neighborData.isVisited;
boolean hasResidualCapacity edgeAttributes.getResidualCapacity scalingFactor;
boolean hasBackwardFlow edgeAttributes.getCurrentFlow scalingFactor;
return notVisited && hasResidualCapacity hasBackwardFlow;
main.java
public static double calculateMaxFlowSimpleGraph graph, Vertex source, Vertex sink
double totalFlow ; Total flow
double maxCapacity GraphUtils.findMaxEdgeCapacitygraph; Find max edge capacity
double scalingFactor GraphUtils.findInitialScalingFactorgraph source; Start with highest power of
Process scaling levels
while scalingFactor
Build the residual graph for the current scaling level
Error here
SimpleGraph residualGraph ResidualGraphBuilder.buildgraph source, sink, scalingFactor;
Augment flow while paths exist
while residualGraphnumEdges
double flowToAdd PathProcessor.processAugmentingPathresidualGraph source;
totalFlow flowToAdd; Update total flow
PathProcessor.updateOriginalGraphgraph residualGraph, flowToAdd;
residualGraph ResidualGraphBuilder.buildgraph source, sink, ; Rebuild residual graph
Halve the scaling factor
scalingFactor ;
return totalFlow;
Vertex Attributes.java file
package scalingFlowAlgorithm;
public class VertexAttributes
private boolean visited;
public VertexAttributes
this.visited false;
public VertexAttributesboolean visited
this.visited visited;
public boolean isVisited
return visited;
public void setVisitedboolean visited
this.visited visited;
error snip
Error snip
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
