Ask Your Question

Magus's profile - activity

2022-09-29 01:52:10 +0200 commented question Random non-induced subgraph

The algorithm random_subgraph(p) will select each vertex of G independently with probability p but then include ALL the

2022-09-28 14:38:54 +0200 received badge  Student (source)
2022-09-28 07:08:27 +0200 edited question Random non-induced subgraph

Random non-induced subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex is se

2022-09-28 07:08:09 +0200 edited question Random non-induced subgraph

Random non-induced subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex is se

2022-09-28 07:06:59 +0200 edited question Random non-induced subgraph

Random general subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex is select

2022-09-28 06:51:49 +0200 edited question Random non-induced subgraph

Random general subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex is select

2022-09-28 06:50:17 +0200 edited question Random non-induced subgraph

Random connected general subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex

2022-09-28 06:47:05 +0200 edited question Random non-induced subgraph

Random connected general subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex

2022-09-27 23:05:18 +0200 commented question Code for deleting the edges of a subgraph

No, personal interest. I used sage for graph theory once years ago, now I'm starting to use it again, don't know much.

2022-09-27 22:46:44 +0200 commented answer Code for deleting the edges of a subgraph

Thank you so much!

2022-09-27 22:46:07 +0200 marked best answer Code for deleting the edges of a subgraph

Hi all,

I have as inputs a simple graph G and a subgraph H. I want as output the graph G-H, defined as the graph obtained from G by removing the edges of H (without removing any vertices).

H is given like this: H=G.random_subgraph(.25)

Is there a command like G.delete_edges(H) that returns the desired graph?

Thank you.

2022-09-27 22:46:07 +0200 received badge  Scholar (source)
2022-09-27 22:25:43 +0200 asked a question Random non-induced subgraph

Random connected general subgraph Given a graph G then G.random_subgraph(.5) returns a random subgraph of G (each vertex

2022-09-27 22:11:15 +0200 edited question Code for deleting the edges of a subgraph

Code for deleting the edges of a subgraph Hi all, I have as inputs a simple graph G and a subgraph H. I want as output

2022-09-27 22:03:29 +0200 edited question Code for deleting the edges of a subgraph

Code for deleting edges of a subgraph Hi all, I have as inputs a simple graph G and a subgraph H. I want as output the

2022-09-27 20:57:41 +0200 received badge  Editor (source)
2022-09-27 20:57:41 +0200 edited question Code for deleting the edges of a subgraph

Code for deleting edges of a subgraph Hi all, I have as inputs a simple graph G and a subgraph H. I want as output the

2022-09-27 20:55:16 +0200 asked a question Code for deleting the edges of a subgraph

Code for deleting edges of a subgraph Hi all, I have as inputs a simple graph G and a subgraph H. I want as output the

2022-01-03 15:04:21 +0200 received badge  Notable Question (source)
2022-01-03 15:04:21 +0200 received badge  Popular Question (source)
2019-03-12 10:04:15 +0200 asked a question Number of neighbors of a set of vertices in a graph

Hi all, I'd like to know how to get the number of vertices that are adjacent to a given set of vertices in a graph. I have the following skeleton:

from sage.graphs.independent_sets import IndependentSets
G=[some graph]
J=IndependentSets(G)

And I would like to know the number of neighbors of x for each x in J (i.e., the number of vertices of G\x that are adjacent to some vertex in x). Ideally I would like something like:

F=0
t=var('t')
for x in J:
     N=number_of_neighbors(x)
     F += t^N
F

If G is a four cycle then number_of_neighbors(x)=2 for any subset x of two vertices of G, and the polynomial F above should be 1+6t^2 (because there is the empty independent set, 4 independent sets of size 1 each with 2 neighbors, and 2 independent sets of size 2 each with 2 neighbors). I appreciate your help!

2019-03-12 10:04:15 +0200 asked a question Number of vertices of a set of vertices in a graph

Hi all, I'd like to know how to get the number of vertices that are adjacent to a given set of vertices in a graph. I have the following skeleton:

from sage.graphs.independent_sets import IndependentSets G=[some graph] J=IndependentSets(G)

And I would like to know the number of neighbors of x for each x in J (i.e., the number of vertices of G\x that are adjacent to some vertex in x). Ideally I would like something like:

F=0 t=var('t')
for x in J: N=number_of_neighbors(x) F += t^N F

If G is a four cycle then number_of_neighbors(x)=2 for any subset x of two vertices of G, and the polynomial F above should be 1+6t^2 (because there is the empty independent set, 4 independent sets of size 1 each with 2 neighbors, and 2 independent sets of size 2 each with 2 neighbors).