8 lines
352 B
Plaintext
8 lines
352 B
Plaintext
graphresistor[g_, a_, b_] :=
|
|
LinearSolve[
|
|
SparseArray[{{a, a} -> 1, {i_, i_} :> Length@AdjacencyList[g, i],
|
|
Alternatives @@ Join[#, Reverse /@ #] &[
|
|
List @@@ EdgeList[VertexDelete[g, a]]] -> -1}, {VertexCount[
|
|
g], VertexCount[g]}], SparseArray[b -> 1, VertexCount[g]]][[b]];
|
|
N[graphresistor[GridGraph[{10, 10}], 12, 77], 40]
|