What is wrong with Module? or me?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
The following code
does not give me an answer. It looks all is working when each command inside Module
is individually run. But as a Module
, it does not.
Can you tell me what is wrong with my formulation?
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"];
sourceANDsinkF[G_, s_, t_] := Module[e, source, sink,
e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
programming scoping
add a comment |Â
up vote
1
down vote
favorite
The following code
does not give me an answer. It looks all is working when each command inside Module
is individually run. But as a Module
, it does not.
Can you tell me what is wrong with my formulation?
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"];
sourceANDsinkF[G_, s_, t_] := Module[e, source, sink,
e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
programming scoping
How do you call the function you have defined?
– mikado
1 hour ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
@Mikado and @AliH: I call the function assourceANDsinkF[Gr, 1, 2]
for example.
– Tugrul Temel
56 mins ago
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
The following code
does not give me an answer. It looks all is working when each command inside Module
is individually run. But as a Module
, it does not.
Can you tell me what is wrong with my formulation?
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"];
sourceANDsinkF[G_, s_, t_] := Module[e, source, sink,
e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
programming scoping
The following code
does not give me an answer. It looks all is working when each command inside Module
is individually run. But as a Module
, it does not.
Can you tell me what is wrong with my formulation?
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"];
sourceANDsinkF[G_, s_, t_] := Module[e, source, sink,
e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
programming scoping
programming scoping
edited 48 mins ago
J. M. is somewhat okay.♦
94.5k10293454
94.5k10293454
asked 1 hour ago


Tugrul Temel
35811
35811
How do you call the function you have defined?
– mikado
1 hour ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
@Mikado and @AliH: I call the function assourceANDsinkF[Gr, 1, 2]
for example.
– Tugrul Temel
56 mins ago
add a comment |Â
How do you call the function you have defined?
– mikado
1 hour ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
@Mikado and @AliH: I call the function assourceANDsinkF[Gr, 1, 2]
for example.
– Tugrul Temel
56 mins ago
How do you call the function you have defined?
– mikado
1 hour ago
How do you call the function you have defined?
– mikado
1 hour ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
@Mikado and @AliH: I call the function as
sourceANDsinkF[Gr, 1, 2]
for example.– Tugrul Temel
56 mins ago
@Mikado and @AliH: I call the function as
sourceANDsinkF[Gr, 1, 2]
for example.– Tugrul Temel
56 mins ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
What do you want to see?
without the module:
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"]
e = DeleteDuplicates[EdgeList[Gr]]
source = Cases[e, 1 [DirectedEdge] _]
1 [DirectedEdge] 2, 1 [DirectedEdge] 5
sink = Cases[e, _ [DirectedEdge] 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
with the module
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
sourceANDsinkF[Gr, 1, 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
or
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t];
source, sink];
sourceANDsinkF[Gr, 1, 2]
Dear All, I am really surprised that none of the proposals above are working in my version ofMathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?
– Tugrul Temel
14 mins ago
My goal is: givenGr
, I want to find all outgoing edges fromsource
vertex and calculate the sum of the associated edge weights, and do the same for thesink
vertex.
– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
add a comment |Â
up vote
2
down vote
Remove the ";" at the end of Module[...]
, and it should work.
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
What do you want to see?
without the module:
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"]
e = DeleteDuplicates[EdgeList[Gr]]
source = Cases[e, 1 [DirectedEdge] _]
1 [DirectedEdge] 2, 1 [DirectedEdge] 5
sink = Cases[e, _ [DirectedEdge] 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
with the module
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
sourceANDsinkF[Gr, 1, 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
or
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t];
source, sink];
sourceANDsinkF[Gr, 1, 2]
Dear All, I am really surprised that none of the proposals above are working in my version ofMathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?
– Tugrul Temel
14 mins ago
My goal is: givenGr
, I want to find all outgoing edges fromsource
vertex and calculate the sum of the associated edge weights, and do the same for thesink
vertex.
– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
add a comment |Â
up vote
1
down vote
accepted
What do you want to see?
without the module:
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"]
e = DeleteDuplicates[EdgeList[Gr]]
source = Cases[e, 1 [DirectedEdge] _]
1 [DirectedEdge] 2, 1 [DirectedEdge] 5
sink = Cases[e, _ [DirectedEdge] 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
with the module
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
sourceANDsinkF[Gr, 1, 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
or
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t];
source, sink];
sourceANDsinkF[Gr, 1, 2]
Dear All, I am really surprised that none of the proposals above are working in my version ofMathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?
– Tugrul Temel
14 mins ago
My goal is: givenGr
, I want to find all outgoing edges fromsource
vertex and calculate the sum of the associated edge weights, and do the same for thesink
vertex.
– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
What do you want to see?
without the module:
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"]
e = DeleteDuplicates[EdgeList[Gr]]
source = Cases[e, 1 [DirectedEdge] _]
1 [DirectedEdge] 2, 1 [DirectedEdge] 5
sink = Cases[e, _ [DirectedEdge] 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
with the module
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
sourceANDsinkF[Gr, 1, 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
or
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t];
source, sink];
sourceANDsinkF[Gr, 1, 2]
What do you want to see?
without the module:
SeedRandom[02];
Gr = RandomGraph[6, 10, DirectedEdges -> True, VertexLabels -> "Name"]
e = DeleteDuplicates[EdgeList[Gr]]
source = Cases[e, 1 [DirectedEdge] _]
1 [DirectedEdge] 2, 1 [DirectedEdge] 5
sink = Cases[e, _ [DirectedEdge] 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
with the module
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t]];
sourceANDsinkF[Gr, 1, 2]
1 [DirectedEdge] 2, 3 [DirectedEdge] 2
or
sourceANDsinkF[G_, s_, t_] :=
Module[e, source, sink, e = DeleteDuplicates[EdgeList[G]];
source = Cases[e, s [DirectedEdge] _];
sink = Cases[e, _ [DirectedEdge] t];
source, sink];
sourceANDsinkF[Gr, 1, 2]
answered 26 mins ago
rmw
2196
2196
Dear All, I am really surprised that none of the proposals above are working in my version ofMathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?
– Tugrul Temel
14 mins ago
My goal is: givenGr
, I want to find all outgoing edges fromsource
vertex and calculate the sum of the associated edge weights, and do the same for thesink
vertex.
– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
add a comment |Â
Dear All, I am really surprised that none of the proposals above are working in my version ofMathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?
– Tugrul Temel
14 mins ago
My goal is: givenGr
, I want to find all outgoing edges fromsource
vertex and calculate the sum of the associated edge weights, and do the same for thesink
vertex.
– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
Dear All, I am really surprised that none of the proposals above are working in my version of
Mathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?– Tugrul Temel
14 mins ago
Dear All, I am really surprised that none of the proposals above are working in my version of
Mathematica 10
, although you all show that my formulation should also work fine. I really do not know what else I can do. Any idea?– Tugrul Temel
14 mins ago
My goal is: given
Gr
, I want to find all outgoing edges from source
vertex and calculate the sum of the associated edge weights, and do the same for the sink
vertex.– Tugrul Temel
6 mins ago
My goal is: given
Gr
, I want to find all outgoing edges from source
vertex and calculate the sum of the associated edge weights, and do the same for the sink
vertex.– Tugrul Temel
6 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
Too bad, maybe an update to version 12 is possible? I did the calculations with version 11.3. Unfortunately, I can not help technically, is not my field of expertise.
– rmw
2 mins ago
add a comment |Â
up vote
2
down vote
Remove the ";" at the end of Module[...]
, and it should work.
add a comment |Â
up vote
2
down vote
Remove the ";" at the end of Module[...]
, and it should work.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Remove the ";" at the end of Module[...]
, and it should work.
Remove the ";" at the end of Module[...]
, and it should work.
answered 29 mins ago


t-smart
830114
830114
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f183755%2fwhat-is-wrong-with-module-or-me%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
How do you call the function you have defined?
– mikado
1 hour ago
did you call the function? sourceANDsinkF[Gr,1,2] ??
– Ali Hashmi
59 mins ago
@Mikado and @AliH: I call the function as
sourceANDsinkF[Gr, 1, 2]
for example.– Tugrul Temel
56 mins ago