MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / setEdge

Method setEdge

src/main/java/com/thealgorithms/others/PageRank.java:92–98  ·  view source on GitHub ↗

Sets an edge in the adjacency matrix @param from source node (1-indexed) @param to destination node (1-indexed) @param value 1 if edge exists, 0 otherwise

(int from, int to, int value)

Source from the content-addressed store, hash-verified

90 * @param value 1 if edge exists, 0 otherwise
91 */
92 public void setEdge(int from, int to, int value) {
93 if (from == to) {
94 adjacencyMatrix[from][to] = 0; // No self-loops
95 } else {
96 adjacencyMatrix[from][to] = value;
97 }
98 }
99
100 /**
101 * Sets the adjacency matrix for the graph

Callers 15

testTwoNodeGraphMethod · 0.95
testHubAndSpokeGraphMethod · 0.95
testGetPageRankMethod · 0.95
testGetAllPageRanksMethod · 0.95
testNoSelfLoopsMethod · 0.95
testInvalidIterationsMethod · 0.95
testComplexGraphMethod · 0.95
testPageRankSumMethod · 0.95

Calls

no outgoing calls

Tested by 13

testTwoNodeGraphMethod · 0.76
testHubAndSpokeGraphMethod · 0.76
testGetPageRankMethod · 0.76
testGetAllPageRanksMethod · 0.76
testNoSelfLoopsMethod · 0.76
testInvalidIterationsMethod · 0.76
testComplexGraphMethod · 0.76
testPageRankSumMethod · 0.76