0
|
2849 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# error during execution function (cannot evaluate twice)

Posted 11 years ago
 Hello to all, I am a newbie to Mathematica. My problem is the first time I run the code works, however, if I run it then it no longer works (without recreating the graph).Why? listMaxNodeGraph[grafo_] :=    Block[{g = grafo},     Pick[VertexList[g], VertexDegree[g], Max[VertexDegree[g]]]]; singleNodeMaxGraph[grafo_] :=    Block[{g = grafo}, listMaxNodeGraph[g][[1]]]; degreeMaxNodeGraph[grafo_] :=    Block[{g = grafo}, VertexDegree[g, singleNodeMaxGraph[g]]]; findNotNeighbour[grafo_, vertice_] :=    Block[{g = grafo, v = vertice},    Pick[VertexList[g], AdjacencyMatrix[g][[VertexIndex[g, v]]], 0]];findNotNeighbourUn[grafo_, vertice_] := Block[{g = grafo, v = vertice, notNei},   Delete[notNei = findNotNeighbour[g, v],    Position[notNei, v]]];(*Vu^**)calculatePowerSet[grafo_] := Block[{g = grafo,    li}, (li = findNotNeighbourUn[g, singleNodeMaxGraph[g]];   Subsets[li, {1, Length[li]}])];calculateIndipendentSubSet[grafo_] :=   Block[{g = grafo, grafoU, powerSet,     x}, (grafoU = VertexDelete[g, singleNodeMaxGraph[g]];    powerSet = calculatePowerSet[g];    Pick[powerSet,      Table[IndependentVertexSetQ[grafoU, x], {x, powerSet}]])];listSubGraphIndipendent[grafo_] :=   Block[{g = grafo, grafoWithOutU, s,     x}, (grafoWithOutU = VertexDelete[g, singleNodeMaxGraph[g]];    s = calculateIndipendentSubSet[g];    Table[VertexDelete[grafoWithOutU, x], {x, s}])];grafoArt = Graph[{1 \[UndirectedEdge] 2, 1 \[UndirectedEdge] 3,    1 \[UndirectedEdge] 7, 2 \[UndirectedEdge] 3,    2 \[UndirectedEdge] 4, 3 \[UndirectedEdge] 5,    4 \[UndirectedEdge] 5, 4 \[UndirectedEdge] 6,    4 \[UndirectedEdge] 7, 5 \[UndirectedEdge] 7,    6 \[UndirectedEdge] 7, 6 \[UndirectedEdge] 8,    7 \[UndirectedEdge] 8, 8 \[UndirectedEdge] 9,    5 \[UndirectedEdge] 9}, GraphStyle -> "VintageDiagram"]listSubGraphIndipendent[grafoArt]
2 Replies
Sort By:
Posted 11 years ago
 Hi Matteo,I can't reproduce the problem, the code simply produces the same graph upon every evaluation for me. Have you tried this after a kernel restart? Maybe some of your symbols had old definitions that you forgot about but that interfered with the final version of the code...Sorry I can't be more helpful.Kind regards,Bianca
Posted 11 years ago
 hi Bianca,  my problem is execute more times the function listSubGraphIndipendent with out  recreate  the graph.The first result is correct and the subsequent results are incorrect.