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

                    Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

                    Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

                    How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page