How to remove an edge attribute in python-igraphHow do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonDoes Python have a string 'contains' substring method?
Email Account under attack (really) - anything I can do?
Could a US political party gain complete control over the government by removing checks & balances?
How to make payment on the internet without leaving a money trail?
What to wear for invited talk in Canada
What happens when a metallic dragon and a chromatic dragon mate?
Map list to bin numbers
Why was the "bread communication" in the arena of Catching Fire left out in the movie?
What causes the sudden spool-up sound from an F-16 when enabling afterburner?
Does the average primeness of natural numbers tend to zero?
Where else does the Shulchan Aruch quote an authority by name?
Is there any use for defining additional entity types in a SOQL FROM clause?
Creating a loop after a break using Markov Chain in Tikz
Can I legally use front facing blue light in the UK?
What is GPS' 19 year rollover and does it present a cybersecurity issue?
New order #4: World
Finding files for which a command fails
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore
Why do we use polarized capacitors?
Does it makes sense to buy a new cycle to learn riding?
COUNT(*) or MAX(id) - which is faster?
How to move the player while also allowing forces to affect it
Is this food a bread or a loaf?
"My colleague's body is amazing"
How to remove an edge attribute in python-igraph
How do I check whether a file exists without exceptions?Calling an external command in PythonWhat are metaclasses in Python?How can I safely create a nested directory in Python?How can I remove a trailing newline in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?How to know if an object has an attribute in PythonDoes Python have a string 'contains' substring method?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I want to remove an edge attribute from a Graph object in python-igraph
. The equivalent igraph R function is cleverly called delete_edge_attr
. I haven't been able to find an equivalent function/method in Python... is there one?
If not, is there another way to do it? (I tried a simple g.es['edge_attr']= []
but this didn't work).
Example Code
g = ig.Graph.Tree(10, 2) #Generate random graph
g_betweenness = g.betweenness() #Calculate betweenness for graph
g['betweenness'] = betweenness #Assign betweenness as edge attribute
print(g.attributes())
g['betweenness'] = [] #Attempt to remove betweenness edge attribute (incorrect)
print(g.attributes())
Output
['betweenness']
['betweenness']
Desired output
['betweenness']
[]
python python-3.x igraph
add a comment |
I want to remove an edge attribute from a Graph object in python-igraph
. The equivalent igraph R function is cleverly called delete_edge_attr
. I haven't been able to find an equivalent function/method in Python... is there one?
If not, is there another way to do it? (I tried a simple g.es['edge_attr']= []
but this didn't work).
Example Code
g = ig.Graph.Tree(10, 2) #Generate random graph
g_betweenness = g.betweenness() #Calculate betweenness for graph
g['betweenness'] = betweenness #Assign betweenness as edge attribute
print(g.attributes())
g['betweenness'] = [] #Attempt to remove betweenness edge attribute (incorrect)
print(g.attributes())
Output
['betweenness']
['betweenness']
Desired output
['betweenness']
[]
python python-3.x igraph
add a comment |
I want to remove an edge attribute from a Graph object in python-igraph
. The equivalent igraph R function is cleverly called delete_edge_attr
. I haven't been able to find an equivalent function/method in Python... is there one?
If not, is there another way to do it? (I tried a simple g.es['edge_attr']= []
but this didn't work).
Example Code
g = ig.Graph.Tree(10, 2) #Generate random graph
g_betweenness = g.betweenness() #Calculate betweenness for graph
g['betweenness'] = betweenness #Assign betweenness as edge attribute
print(g.attributes())
g['betweenness'] = [] #Attempt to remove betweenness edge attribute (incorrect)
print(g.attributes())
Output
['betweenness']
['betweenness']
Desired output
['betweenness']
[]
python python-3.x igraph
I want to remove an edge attribute from a Graph object in python-igraph
. The equivalent igraph R function is cleverly called delete_edge_attr
. I haven't been able to find an equivalent function/method in Python... is there one?
If not, is there another way to do it? (I tried a simple g.es['edge_attr']= []
but this didn't work).
Example Code
g = ig.Graph.Tree(10, 2) #Generate random graph
g_betweenness = g.betweenness() #Calculate betweenness for graph
g['betweenness'] = betweenness #Assign betweenness as edge attribute
print(g.attributes())
g['betweenness'] = [] #Attempt to remove betweenness edge attribute (incorrect)
print(g.attributes())
Output
['betweenness']
['betweenness']
Desired output
['betweenness']
[]
python python-3.x igraph
python python-3.x igraph
edited Mar 22 at 3:06
Josh
asked Mar 22 at 1:53
JoshJosh
409
409
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You might not be able to set it to an empty array, but your intuition about directly altering the EdgeSequence
was already pretty good. You can simply delete the argument with Python's internal del()
, I've included a minimal example below:
import igraph
# minimal graph
G = igraph.Graph()
G.add_vertices(2)
G.add_edge(0,1)
# add your property
G.es['betweenness'] = [1]
# print edge attribute (note the difference to your example)
print(G.es.attribute_names())
# output: ['weight']
# delete argument
del(G.es['weight'])
# print again
print(G.es.attribute_names())
# output: []
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
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%2f55291777%2fhow-to-remove-an-edge-attribute-in-python-igraph%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
You might not be able to set it to an empty array, but your intuition about directly altering the EdgeSequence
was already pretty good. You can simply delete the argument with Python's internal del()
, I've included a minimal example below:
import igraph
# minimal graph
G = igraph.Graph()
G.add_vertices(2)
G.add_edge(0,1)
# add your property
G.es['betweenness'] = [1]
# print edge attribute (note the difference to your example)
print(G.es.attribute_names())
# output: ['weight']
# delete argument
del(G.es['weight'])
# print again
print(G.es.attribute_names())
# output: []
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
add a comment |
You might not be able to set it to an empty array, but your intuition about directly altering the EdgeSequence
was already pretty good. You can simply delete the argument with Python's internal del()
, I've included a minimal example below:
import igraph
# minimal graph
G = igraph.Graph()
G.add_vertices(2)
G.add_edge(0,1)
# add your property
G.es['betweenness'] = [1]
# print edge attribute (note the difference to your example)
print(G.es.attribute_names())
# output: ['weight']
# delete argument
del(G.es['weight'])
# print again
print(G.es.attribute_names())
# output: []
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
add a comment |
You might not be able to set it to an empty array, but your intuition about directly altering the EdgeSequence
was already pretty good. You can simply delete the argument with Python's internal del()
, I've included a minimal example below:
import igraph
# minimal graph
G = igraph.Graph()
G.add_vertices(2)
G.add_edge(0,1)
# add your property
G.es['betweenness'] = [1]
# print edge attribute (note the difference to your example)
print(G.es.attribute_names())
# output: ['weight']
# delete argument
del(G.es['weight'])
# print again
print(G.es.attribute_names())
# output: []
You might not be able to set it to an empty array, but your intuition about directly altering the EdgeSequence
was already pretty good. You can simply delete the argument with Python's internal del()
, I've included a minimal example below:
import igraph
# minimal graph
G = igraph.Graph()
G.add_vertices(2)
G.add_edge(0,1)
# add your property
G.es['betweenness'] = [1]
# print edge attribute (note the difference to your example)
print(G.es.attribute_names())
# output: ['weight']
# delete argument
del(G.es['weight'])
# print again
print(G.es.attribute_names())
# output: []
answered Mar 26 at 8:52
dennlingerdennlinger
1,98911024
1,98911024
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
add a comment |
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
Perfect thanks! I knew there had to be a simple solution
– Josh
Mar 27 at 3:34
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%2f55291777%2fhow-to-remove-an-edge-attribute-in-python-igraph%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