There are many articles in this site regarding my question. I have a matrix for example (10 x 10) which represents 10 nodes. The matrix called MyMat(9,9)
The rows of this matrix represent the source node (From Node) and the columns represents target node (To Node). It has 14 links which are randomly distributed. The non zero values represent the connections between nodes.
0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 1 0 0 0 0
What I want is to prevent the loops (cycles) for each node in the system. For example: Node 1: No loop
Node 2: 2, 9, 7, 8, 10, 2. Here the loop exists because it started with 2 and finished with 2. What I want to prevent the loops in this network. This means that: MyMat(9,1) must be 0 Node 2: 2, 9, 7, 8, 10, 3, 2. This means MyMat(2,1) must be 0
Node 3: No loop
Node 4: 4, 7, 8, 4. This means that MyMat(7,3) must be 0
Node 5: 5, 8, 10, 6, 5. This means that MyMat(5,4) must be 0
Node 6: No Loop
Node 7: No Loop
Node 8: No Loop
Node 9: No Loop
Node 10: No Loop
4 connections were deleted from above matrix.
I have done this via a technique called Depth first search but it is very slow and burden the running time of my programme especially when I use 60 nodes and 100 connections!! Several programming examples can found if you Google it.
Is there an easier (quicker) way for doing this in visual basic or C#?