I am new to this site, I apologise if this is in the wrong place or the format or something else is wrong.
I am looking to extend the following code to accommodate Ford-Fulkerson's Max Flow, but I am not sure where to begin. The code needs to use the existing code as a base, so that both algorithms are in the same Python.

To clarify A>D in the separate Path file is path for Dijkstra when the code is executed.

I hope this makes sense. I am new to Python, but eager to learn.

The code needs to do the following:

--- AIMS ---

Read in a file called “network.txt” – a multi-line file with node, nearest neighbour and distance metric information
Read in a file called “path.txt” – a single line file with start and destination information, where the line is of the form “A>D” (any start / end combination is possible)
Print out to the screen every path discovered during the calculation, along with its associated bottleneck flow value
Then print out the total max flow for the network

--- Network.txt ---


--- Path.txt ---



infinity = 1000000
invalid_node = -1

class Node:
    previous = invalid_node
    distanceFromSource = infinity
    visited = False

def populateNetworkTable():
    # array containing array of values for each line
    network = []
    networkFile = open("network.txt", "r")
    numberOfNodes = 0
    # reading network.txt file a line at a time
    for line in networkFile:
        # increment nodeCount
        numberOfNodes += 1
        network.append(map(int, line.strip().split(',')))
    return network

def populateNodeTable():
    # array containing nodeTable visited/unvisited,prevNode and distFromSrc
    nodeTable = []
    i = 0
    for i in range(len(network)):
    # set distFromSource of startNode to 0
    nodeTable[startNode].distanceFromSource = 0
    nodeTable[startNode].visited = True
    return nodeTable

# go through all distances of unvisited, find the one with lowest dist
def setNewCurrentNode(nodeTable):
    nextNode = -1  
    nodeIndex = 0
    nextDistance = infinity
    for node in nodeTable:
        if node.visited == False and node.distanceFromSource < nextDistance:
            nextNode = nodeIndex
            nextDistance = node.distanceFromSource
    return nextNode

# the following finds each of the neighbours of current node
def findNeighbour(currentNode):
    # find nearest neighbour of currentNode
    currentRow = network[currentNode]
    currentNeighbours = []
    i = 0
    for distance in currentRow:
        #get back the index number / position if distance = 0
        if distance != 0:
            #save the location
        i += 1   
    return currentNeighbours
def readRoute():
    routeFile = open("route.txt", "r")
    for line in routeFile:
        nodes = line.split(">")
        startNode = nodes[0]
        endNode = nodes[1]
    startNode =(ord(startNode) - 65)
    endNode =(ord(endNode) - 65)
    return startNode, endNode

def calculateRoute(nodeTable,currentNode,startNode):
    route = []
    while True:
        if currentNode == startNode:
        currentNode = nodeTable[currentNode].previous
    route = "".join(chr(node+65) for node in route)
    return route

# go through nodeTable and add distance and previous if unvisited
def calculateTentativeDistance(nodeTable,currentNeighbours):
    for neighbour in currentNeighbours:
        if nodeTable[neighbour].visited == True:
            # calculate tentative distances
            newDistance = nodeTable[currentNode].distanceFromSource + network[currentNode][neighbour]
            if (nodeTable[neighbour].distanceFromSource > newDistance):
                 nodeTable[neighbour].distanceFromSource = newDistance
                 nodeTable[neighbour].previous = currentNode
    return nodeTable

def calculateMaxFlow()

#create network table
network = populateNetworkTable()

#get startNode and endNode from file
startNode, endNode = readRoute()

# set currentNode to startNode
currentNode = startNode

# create Node table
nodeTable = populateNodeTable()

# continue until desination reached
while currentNode != endNode:
    # get list of current neighbours
    currentNeighbours = findNeighbour(currentNode)
    # set current node as visited
    nodeTable[currentNode].visited = True
    # get new nodeTable
    nodeTable = calculateTentativeDistance(nodeTable,currentNeighbours)
    # set new current node
    currentNode = setNewCurrentNode(nodeTable)
    # get the route solution
    route = calculateRoute(nodeTable,currentNode, startNode)

print("The shortest route is: " + route)
print("The tentative distance is: " + str(nodeTable[currentNode].distanceFromSource))