How to specify the vertice order and the edge order when obtaining the incidence matrix of a digraph in sage?Python sage: How do I computer a nullspace (kernel) for a stoichiometric matrix?How to change frame and axes when save plot as eps in sagehow to obtain leaf count (expression size) in sage?How to create vector circulant matrix in Sage?how to re-order polynomial term factors from sage outputExpand large polynomial with Sage (List colouring, combinatorial Nullstellensatz)How to define the variable as a matrix in sage?How to compose two partial orders in Sage?Combinatorially generating subgraphs between a given upper and lower bound (Sage)How to specify a multiplication in the objective function of a Sage mixed integer linear program?
Prove that NP is closed under karp reduction?
Is it possible to do 50 km distance without any previous training?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
What are these boxed doors outside store fronts in New York?
To string or not to string
In Japanese, what’s the difference between “Tonari ni” (となりに) and “Tsugi” (つぎ)? When would you use one over the other?
Mathematical cryptic clues
Is it unprofessional to ask if a job posting on GlassDoor is real?
Expeditious Retreat
Risk of getting Chronic Wasting Disease (CWD) in the United States?
"to be prejudice towards/against someone" vs "to be prejudiced against/towards someone"
Do I have a twin with permutated remainders?
What do the dots in this tr command do: tr .............A-Z A-ZA-Z <<< "JVPQBOV" (with 13 dots)
How could an uplifted falcon's brain work?
Smoothness of finite-dimensional functional calculus
What is the offset in a seaplane's hull?
Why not use SQL instead of GraphQL?
Has the BBC provided arguments for saying Brexit being cancelled is unlikely?
How did the USSR manage to innovate in an environment characterized by government censorship and high bureaucracy?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
Modeling an IPv4 Address
An academic/student plagiarism
How to write a macro that is braces sensitive?
Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?
How to specify the vertice order and the edge order when obtaining the incidence matrix of a digraph in sage?
Python sage: How do I computer a nullspace (kernel) for a stoichiometric matrix?How to change frame and axes when save plot as eps in sagehow to obtain leaf count (expression size) in sage?How to create vector circulant matrix in Sage?how to re-order polynomial term factors from sage outputExpand large polynomial with Sage (List colouring, combinatorial Nullstellensatz)How to define the variable as a matrix in sage?How to compose two partial orders in Sage?Combinatorially generating subgraphs between a given upper and lower bound (Sage)How to specify a multiplication in the objective function of a Sage mixed integer linear program?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
We can obtain the incidence matrix of a digraph using the method incidence_matrix(oriented=None, sparse=True, vertices=None)
in SageMath.
Each row is a vertex, and each column is an edge. The vertices are ordered as obtained by the method
vertices()
, except when parametervertices
is given, and the edges as obtained by the methodedge_iterator()
.
My question is how to specify the vertice order and the edge order?
For example, g
is a weighted digraph with 10 edges:
edges = [('s', 'x', 3), ('s', 'y', 5),
('x', 'y', 2), ('x', 'z', 6),
('y', 'x', 1), ('y', 'z', 4), ('y', 't', 6),
('z', 't', 2),
('t', 's', 3), ('t', 'z', 7)]
g = DiGraph(edges)
I want to arrange the incidence matrix such that the vertices (from top to down) are ordered as s, x, y, z, t
and the edges are ordered (from left to right) as those in edges
(i.e., listing the edges in the alphabetic order s, x, y, z, t
).
sage
add a comment |
We can obtain the incidence matrix of a digraph using the method incidence_matrix(oriented=None, sparse=True, vertices=None)
in SageMath.
Each row is a vertex, and each column is an edge. The vertices are ordered as obtained by the method
vertices()
, except when parametervertices
is given, and the edges as obtained by the methodedge_iterator()
.
My question is how to specify the vertice order and the edge order?
For example, g
is a weighted digraph with 10 edges:
edges = [('s', 'x', 3), ('s', 'y', 5),
('x', 'y', 2), ('x', 'z', 6),
('y', 'x', 1), ('y', 'z', 4), ('y', 't', 6),
('z', 't', 2),
('t', 's', 3), ('t', 'z', 7)]
g = DiGraph(edges)
I want to arrange the incidence matrix such that the vertices (from top to down) are ordered as s, x, y, z, t
and the edges are ordered (from left to right) as those in edges
(i.e., listing the edges in the alphabetic order s, x, y, z, t
).
sage
add a comment |
We can obtain the incidence matrix of a digraph using the method incidence_matrix(oriented=None, sparse=True, vertices=None)
in SageMath.
Each row is a vertex, and each column is an edge. The vertices are ordered as obtained by the method
vertices()
, except when parametervertices
is given, and the edges as obtained by the methodedge_iterator()
.
My question is how to specify the vertice order and the edge order?
For example, g
is a weighted digraph with 10 edges:
edges = [('s', 'x', 3), ('s', 'y', 5),
('x', 'y', 2), ('x', 'z', 6),
('y', 'x', 1), ('y', 'z', 4), ('y', 't', 6),
('z', 't', 2),
('t', 's', 3), ('t', 'z', 7)]
g = DiGraph(edges)
I want to arrange the incidence matrix such that the vertices (from top to down) are ordered as s, x, y, z, t
and the edges are ordered (from left to right) as those in edges
(i.e., listing the edges in the alphabetic order s, x, y, z, t
).
sage
We can obtain the incidence matrix of a digraph using the method incidence_matrix(oriented=None, sparse=True, vertices=None)
in SageMath.
Each row is a vertex, and each column is an edge. The vertices are ordered as obtained by the method
vertices()
, except when parametervertices
is given, and the edges as obtained by the methodedge_iterator()
.
My question is how to specify the vertice order and the edge order?
For example, g
is a weighted digraph with 10 edges:
edges = [('s', 'x', 3), ('s', 'y', 5),
('x', 'y', 2), ('x', 'z', 6),
('y', 'x', 1), ('y', 'z', 4), ('y', 't', 6),
('z', 't', 2),
('t', 's', 3), ('t', 'z', 7)]
g = DiGraph(edges)
I want to arrange the incidence matrix such that the vertices (from top to down) are ordered as s, x, y, z, t
and the edges are ordered (from left to right) as those in edges
(i.e., listing the edges in the alphabetic order s, x, y, z, t
).
sage
sage
edited Mar 9 at 7:50
hengxin
asked Mar 9 at 2:36
hengxinhengxin
83421232
83421232
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
A quick look at the code (which you can obtain by doing g.edge_iterator??
) for edge_iterator()
suggests
The iterator returned is over the edges incident with any vertex
given in the parameter "vertices".
if oriented:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
if i != j:
m[verts[i],e] = -1
m[verts[j],e] = +1
else:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
m[verts[i],e] += 1
m[verts[j],e] += 1
tells me that probably one would have to hack the code for this a bit to change the order.
This seems like a reasonable request to have this customizable, so I've opened Sage Trac ticket 27513 for this.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073473%2fhow-to-specify-the-vertice-order-and-the-edge-order-when-obtaining-the-incidence%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
A quick look at the code (which you can obtain by doing g.edge_iterator??
) for edge_iterator()
suggests
The iterator returned is over the edges incident with any vertex
given in the parameter "vertices".
if oriented:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
if i != j:
m[verts[i],e] = -1
m[verts[j],e] = +1
else:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
m[verts[i],e] += 1
m[verts[j],e] += 1
tells me that probably one would have to hack the code for this a bit to change the order.
This seems like a reasonable request to have this customizable, so I've opened Sage Trac ticket 27513 for this.
add a comment |
A quick look at the code (which you can obtain by doing g.edge_iterator??
) for edge_iterator()
suggests
The iterator returned is over the edges incident with any vertex
given in the parameter "vertices".
if oriented:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
if i != j:
m[verts[i],e] = -1
m[verts[j],e] = +1
else:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
m[verts[i],e] += 1
m[verts[j],e] += 1
tells me that probably one would have to hack the code for this a bit to change the order.
This seems like a reasonable request to have this customizable, so I've opened Sage Trac ticket 27513 for this.
add a comment |
A quick look at the code (which you can obtain by doing g.edge_iterator??
) for edge_iterator()
suggests
The iterator returned is over the edges incident with any vertex
given in the parameter "vertices".
if oriented:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
if i != j:
m[verts[i],e] = -1
m[verts[j],e] = +1
else:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
m[verts[i],e] += 1
m[verts[j],e] += 1
tells me that probably one would have to hack the code for this a bit to change the order.
This seems like a reasonable request to have this customizable, so I've opened Sage Trac ticket 27513 for this.
A quick look at the code (which you can obtain by doing g.edge_iterator??
) for edge_iterator()
suggests
The iterator returned is over the edges incident with any vertex
given in the parameter "vertices".
if oriented:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
if i != j:
m[verts[i],e] = -1
m[verts[j],e] = +1
else:
for e, (i, j) in enumerate(self.edge_iterator(labels=False)):
m[verts[i],e] += 1
m[verts[j],e] += 1
tells me that probably one would have to hack the code for this a bit to change the order.
This seems like a reasonable request to have this customizable, so I've opened Sage Trac ticket 27513 for this.
answered Mar 19 at 17:45
kcrismankcrisman
3,6041336
3,6041336
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073473%2fhow-to-specify-the-vertice-order-and-the-edge-order-when-obtaining-the-incidence%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown