Ask Your Question

gvdr's profile - activity

2018-09-18 13:34:22 +0200 received badge  Notable Question (source)
2017-02-20 06:55:48 +0200 received badge  Popular Question (source)
2013-05-28 19:40:41 +0200 commented answer large matrices

Yep, I was working with some "big matrix" (some 50x50) and I have the same bug (sage 5.8 on a windows Mozilla firefox)... Seems SAGE is not happy to print a matrix bigger than a 19x19 (but has no problem if is just a list).

2013-05-27 15:35:37 +0200 received badge  Scholar (source)
2013-05-27 15:35:37 +0200 marked best answer motifs and subgraphs

First of all, you do not need numpy to initialize a graph. Simply write

M1 = DiGraph(matrix([[0,1,0],[0,0,1],[0,0,0]])) #first motif
M5 = DiGraph(matrix([[0,1,1],[0,0,1],[0,0,0]])) #second motif

Your question is documented in subgraph_search, subgraph_search_iterator and subgraph_search_count. You can access the documentation through

sage: G = DiGraph()
sage: G.subgraph_search?

There is an option induced which allows you to search only for induced subgraph and which is False by default.

sage: M5.subgraph_search_count(M1)
1
sage: M5.subgraph_search_count(M1,induced=True)
0
2013-05-27 15:35:35 +0200 received badge  Supporter (source)
2013-05-27 15:35:26 +0200 commented answer motifs and subgraphs

Yep, the induce option works! I overview that part (but take into account the automorphism group cardinality...). Thanks twice.

2013-05-27 15:26:29 +0200 commented answer motifs and subgraphs

Thanks, I use numpy as I have to do some matrices manipulation on the starting graph. But thanks for the reminder!

2013-05-27 02:03:00 +0200 received badge  Editor (source)
2013-05-27 02:02:15 +0200 asked a question motifs and subgraphs

I'm counting the number of motifs (3-nodes isophormic class of connected subgraphs) in a random directed network. There are 13 of this. One is, for example S1={1 -> 2, 2 -> 3} and another one S2={1 -> 2, 2 -> 3, 1 -> 3}. They are two distinct motifs, and I wouldn't count a S1 when I actually find S2. The problem is that S1 is in S2, hence subgraph_search() finds a S1 in each S2 and all related functions inherit the problem (wrong counting, wrong iterator...).

Any idea how to resolve this issue? Similar things would happen for 4-nodes motifs and so on...

The code I used goes like:

import numpy
M1 = DiGraph(numpy.array([[0,1,0],[0,0,1],[0,0,0]])) #first motif
M5 = DiGraph(numpy.array([[0,1,1],[0,0,1],[0,0,0]])) #second motif
g = digraphs.RandomDirectedGNP(20,0.1) #a random network
l1 = []
for p in g.subgraph_search_iterator(M1): #search first motif
  l1.append(p) #make a list of its occurences
l5 = []
for p in g.subgraph_search_iterator(M5): #the same for the second motif
  l5.append(p)