Skip to content

Commit 40ea72f

Browse files
committed
- added intersection
1 parent 604850e commit 40ea72f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/test-intrs.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import snap
2+
3+
# first vector
4+
a = snap.TIntV()
5+
a.Add(1)
6+
a.Add(2)
7+
a.Add(3)
8+
a.Add(4)
9+
a.Add(5)
10+
l = [ str(elem) for elem in a]
11+
print "a ", ", ".join(l)
12+
13+
# second vector
14+
b = snap.TIntV()
15+
b.Add(3)
16+
b.Add(4)
17+
b.Add(5)
18+
b.Add(6)
19+
b.Add(7)
20+
l = [ str(elem) for elem in b]
21+
print "b ", ", ".join(l)
22+
23+
# third vector
24+
c = snap.TIntV()
25+
c.Add(6)
26+
c.Add(7)
27+
c.Add(8)
28+
c.Add(9)
29+
l = [ str(elem) for elem in c]
30+
print "c ", ", ".join(l)
31+
32+
# intersection
33+
a.Intrs(b)
34+
l = [ str(elem) for elem in a]
35+
print "a^b", ", ".join(l)
36+
l = [ str(elem) for elem in c]
37+
print "c ", ", ".join(l)
38+
39+
# union
40+
a.Union(c)
41+
l = [ str(elem) for elem in a]
42+
print "avc", ", ".join(l)
43+
l = [ str(elem) for elem in c]
44+
print "c ", ", ".join(l)
45+

0 commit comments

Comments
 (0)