Converting a graph in networkx to an array of degree of nodes?









up vote
1
down vote

favorite












A beginner in this area here.



I am looking to to make a function which takes input as a graph and returns an array with degree of all nodes like



[1 2 3
4 5 2]



corresponding to 1st node having a degree of 1..?



I have made a function that returns a graph.
Now I want to use this graph and return an array.



Is there a way to convert a graph with a built in function? I tried numpy_to_matrix but that doesn't work.










share|improve this question























  • networkx.degree(graph) or graph.degree (IIRC)
    – Paul Brodersen
    Nov 11 at 13:24










  • Thanks. What does IIRC stand for?
    – NewYork
    Nov 12 at 0:30










  • If I recall correctly
    – Paul Brodersen
    Nov 12 at 13:35














up vote
1
down vote

favorite












A beginner in this area here.



I am looking to to make a function which takes input as a graph and returns an array with degree of all nodes like



[1 2 3
4 5 2]



corresponding to 1st node having a degree of 1..?



I have made a function that returns a graph.
Now I want to use this graph and return an array.



Is there a way to convert a graph with a built in function? I tried numpy_to_matrix but that doesn't work.










share|improve this question























  • networkx.degree(graph) or graph.degree (IIRC)
    – Paul Brodersen
    Nov 11 at 13:24










  • Thanks. What does IIRC stand for?
    – NewYork
    Nov 12 at 0:30










  • If I recall correctly
    – Paul Brodersen
    Nov 12 at 13:35












up vote
1
down vote

favorite









up vote
1
down vote

favorite











A beginner in this area here.



I am looking to to make a function which takes input as a graph and returns an array with degree of all nodes like



[1 2 3
4 5 2]



corresponding to 1st node having a degree of 1..?



I have made a function that returns a graph.
Now I want to use this graph and return an array.



Is there a way to convert a graph with a built in function? I tried numpy_to_matrix but that doesn't work.










share|improve this question















A beginner in this area here.



I am looking to to make a function which takes input as a graph and returns an array with degree of all nodes like



[1 2 3
4 5 2]



corresponding to 1st node having a degree of 1..?



I have made a function that returns a graph.
Now I want to use this graph and return an array.



Is there a way to convert a graph with a built in function? I tried numpy_to_matrix but that doesn't work.







python-3.x networkx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 0:31

























asked Nov 11 at 1:34









NewYork

243




243











  • networkx.degree(graph) or graph.degree (IIRC)
    – Paul Brodersen
    Nov 11 at 13:24










  • Thanks. What does IIRC stand for?
    – NewYork
    Nov 12 at 0:30










  • If I recall correctly
    – Paul Brodersen
    Nov 12 at 13:35
















  • networkx.degree(graph) or graph.degree (IIRC)
    – Paul Brodersen
    Nov 11 at 13:24










  • Thanks. What does IIRC stand for?
    – NewYork
    Nov 12 at 0:30










  • If I recall correctly
    – Paul Brodersen
    Nov 12 at 13:35















networkx.degree(graph) or graph.degree (IIRC)
– Paul Brodersen
Nov 11 at 13:24




networkx.degree(graph) or graph.degree (IIRC)
– Paul Brodersen
Nov 11 at 13:24












Thanks. What does IIRC stand for?
– NewYork
Nov 12 at 0:30




Thanks. What does IIRC stand for?
– NewYork
Nov 12 at 0:30












If I recall correctly
– Paul Brodersen
Nov 12 at 13:35




If I recall correctly
– Paul Brodersen
Nov 12 at 13:35

















active

oldest

votes











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',
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%2f53245095%2fconverting-a-graph-in-networkx-to-an-array-of-degree-of-nodes%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245095%2fconverting-a-graph-in-networkx-to-an-array-of-degree-of-nodes%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







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3