laziness, impatience, and hubris PerlMonks

### Re: Finding subgraphs induced by a set of given vertices.

by AnomalousMonk (Canon)
 on Oct 04, 2012 at 17:00 UTC ( #997258=note: print w/replies, xml ) Need Help??

zing: If you run Anonymonk's code of node 997164 with the necessary changes of 997168 and 997253, how does it work for you? It seems to me to produce the results you want given the limited dataset examples you have given.

• Comment on Re: Finding subgraphs induced by a set of given vertices.

Replies are listed 'Best First'.
Re^2: Finding subgraphs induced by a set of given vertices.
by zing (Beadle) on Oct 05, 2012 at 06:38 UTC
AM its now what I want.Here's the output from the code given by anonymous
```Got some? (["b", "c", "a"], { MATCHES => [] })

Got some? (["a", "c", "d"], { MATCHES => [] })

Got some? (["d", "e", "b"], { MATCHES => [["b", "e", "d"]] })
But for T = a b c d I have induced = "b", "c", "a" , "a", "c", "d" .

Similarly for T = b e d output should be = "d", "e", "b" .

Sheisse !!!!! Mein Fehler!!!!
Hi AM, I have posted a problem similar to the one you people have been helping me with at this link http://www.perlmonks.org/?node_id=997708

Re^2: Finding subgraphs induced by a set of given vertices.
by zing (Beadle) on Oct 05, 2012 at 12:29 UTC
The code fails on this data Code
```---------DATA--------------
b c a
a c d
d e b
e f g
g d f
h i g
And the output is
```component 2 = e d g f
component 1 = c a b
b c a
Which is wrong, because it should have been this
```

component 2 = e d g f
e f g
g d f
component 1 = c a b
b c a
Because with the vertices in component 2, we can have 4th & 5th row of DATA. Please help on this
I hope I was clear explaining my problem. Please let me know if you need any other information. Help me on his
Guys the problem is like to check if an array is contained inside another array.
```perl -le '@x = qw(a b c d e f);
@y = qw(a d f);
\$n = grep { \$e = \$_; not grep { \$e =~ /\Q\$_/i } @x } @y;
print "Count of elements in (@y) that are NOT present in (
+@x) = \$n"
'
Count of elements in (a d f) that are NOT present in (a b c d e f) = 0
So if the count is 0, you know that @y is a subset of @x and hence you want to return it from the "induced" subroutine. I hope this would even clear out the mess. Now can this be incorporated as a subroutine. The input will be DATA taken in as an array. The second array will hold the connected components.
```____DATA_____
b c a
a c d
d e b
e f g
g d f
h i g
@Components
```a b c
a b d c
e f d g
So I want to see if any row of @DATA is contained inside @Components. So the output expected is
```component 1 = a b c
induced = b c a
component = a b d c
induced = b c a
a c d
component 3 = e f d g
induced = e f g
g d f

Create A New User
Node Status?
node history
Node Type: note [id://997258]
help
Chatterbox?
 [marto]: oddly the last time I was there I saw a zeppelin in flight for the first time [Corion]: ambrus: I don't know how far the budget estimate has been overrun yet [Corion]: marto: Heh ;) No, you were likely at Tegel or Schönefeld, the new one ("BER") will be somewhat outside of Berlin ;) [marto]: Corion Schoenfeld, but my friend has been telling me about this new airport for about 7-8 years now :P [marto]: I doubt it even exists as a building site :P [ambrus]: Corion: does building airports "somewhat outside of" a city ever work? cities always grow around the airport quickly, because it's practical to be close to it, and after that, people start to complain that the airplanes land so close to their house and sh [ambrus]: ould keep down the noise

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2017-02-23 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Before electricity was invented, what was the Electric Eel called?

Results (346 votes). Check out past polls.