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;








1















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 parameter vertices is given, and the edges as obtained by the method edge_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).










share|improve this question






























    1















    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 parameter vertices is given, and the edges as obtained by the method edge_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).










    share|improve this question


























      1












      1








      1








      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 parameter vertices is given, and the edges as obtained by the method edge_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).










      share|improve this question
















      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 parameter vertices is given, and the edges as obtained by the method edge_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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 7:50







      hengxin

















      asked Mar 9 at 2:36









      hengxinhengxin

      83421232




      83421232






















          1 Answer
          1






          active

          oldest

          votes


















          1














          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.






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            1














            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.






            share|improve this answer



























              1














              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.






              share|improve this answer

























                1












                1








                1







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 19 at 17:45









                kcrismankcrisman

                3,6041336




                3,6041336





























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme