====== Test ======
===== Temporal degree cores =====
==== Links ====
- Seidman, S. B. (1983): [[http://www.sciencedirect.com/science/article/pii/037887338390028X|Network structure and minimum degree]]. Social Networks 5, 269-287
- Batagelj, V, Mrvar, A, Zaveršnik, M: [[http://www.springerlink.com/content/95eyf5p7mpmm9ag8/|Partitioning Approach to Visualization of Large Graphs]]. Graph Drawing, Lecture Notes in Computer Science, 1999, Volume 1731/1999, 90-97. ([[http://vlado.fmf.uni-lj.si/pub/networks/doc/part/CorePart.pdf|preprint]])
- Batagelj, V., Zaveršnik, M.: [[http://www.springerlink.com/content/c6472216637p57w4/|Fast algorithms for determining (generalized) core groups in social networks]]. Advances in Data Analysis and Classification, 2011. Volume 5, Number 2, 129-145. [[http://arxiv.org/abs/cs/0310049|arXiv 1]]+[[http://arxiv.org/abs/cs/0202039|arXiv 2]]
- Cerinšek, M., Batagelj, V.: [[http://www.sciencedirect.com/science/article/pii/S0378873315000271|Generalized two-mode cores]]. Social Networks 42 (2015), 80–87. [[http://arxiv.org/abs/1505.01817|arXiv]]
- Yikai Zhang, Jeffrey Xu Yu, Ying Zhang, Lu Qin: [[https://arxiv.org/abs/1606.00200|A Fast Order-Based Approach for Core Maintenance]]
- Ahmet Erdem Sariyuce, et al.: [[http://www.vldb.org/pvldb/vol6/p433-sariyuce.pdf|Streaming algorithms for k-core decomposition]]
- Rong-Hua Li, Jeffrey Xu Yu, Rui Mao: [[https://www.semanticscholar.org/paper/Efficient-Core-Maintenance-in-Large-Dynamic-Graphs-Li-Yu/00c1eb77aad8d8257a7d86d18038147d922abd97|Efficient core maintenance in large dynamic graphs]]
- Batagelj, V., Praprotnik, S.: An algebraic approach to temporal network analysis based on temporal quantities. [[http://link.springer.com/article/10.1007/s13278-016-0330-4|Social Network Analysis and Mining]], 6(1), 1-22 [[http://link.springer.com/journal/13278|Online]], [[http://arxiv.org/abs/1505.01569|arXiv:1505.01569]]
* AS 2016 {{tq:pub:as2016_tcores.pdf|Slides}}. Ribno, 18-21.9.2016.
* Package [[:tq|TQ]] - Temporal Quantities
* Package [[https://github.com/bavla/Graph|Graph]] - network procedures in Python
* [[notes:net:json|netJson]]
==== Temporal degree cores procedure ====
September 18-19, 2016
gdir = 'c:/users/batagelj/work/python/graph/graph'
wdir = 'c:/users/batagelj/work/python/graph/JSON'
import sys, os, datetime, json
sys.path = [gdir]+sys.path; os.chdir(wdir)
import GraphNew as Graph
import TQ
prLevel = 1
# fJSON = "violenceE.json"
# fJSON = 'stem.json'
# fJSON = 'Terror news 50.json'
# S = Graph.Graph.loadNetJSON(fJSON); G = S.pairs2edges()
fJSON = 'ConnectivityTest.json'
# fJSON = 'ExampleB.json'
# fJSON = 'PathfinderTest.json'
G = Graph.Graph.loadNetJSON(fJSON)
G.delLoops()
print("Temporal cores in: ",fJSON)
t1 = datetime.datetime.now()
print("started: ",t1.ctime(),"\n")
D = { u: G.TQnetDeg(u) for u in G._nodes }
if prLevel<2: print("Deg =",D,"\n")
Core = { u: [d for d in D[u] if d[2]==0] for u in G.nodes() }
# core number = 0
D = { u: [d for d in D[u] if d[2]>0] for u in G.nodes() }
D = { u: d for u,d in D.items() if d!=[] }
Dmin = { u: min([e[2] for e in d]) for u,d in D.items() }
step = 0
while len(D)>0:
step += 1
dmin,u = min( (v,k) for k,v in Dmin.items() )
if (step % 10 == 1) or (prLevel < 2):
print("{0:3d}. dmin={1:3d} node={2:4d}".format(step,dmin,u))
core = [ d for d in D[u] if d[2] == dmin ]
Core[u] = TQ.TQ.sum(Core[u],core)
change = TQ.TQ.setConst(core,-1)
D[u] = TQ.TQ.cutGE(TQ.TQ.sum(D[u],change),dmin)
for link in G.star(u):
v = G.twin(u,link)
if not(v in D): continue
chLink = TQ.TQ.extract(G.getLink(link,'tq'),change)
if chLink==[]: continue
diff = TQ.TQ.cutGE(TQ.TQ.sum(D[v],chLink),0)
D[v] = TQ.TQ.standard([ (sd,fd,max(vd,dmin)) for sd,fd,vd in diff ])
if len(D[v])==0: del D[v]; del Dmin[v]
else: Dmin[v] = min([e[2] for e in D[v]])
if len(D[u])==0: del D[u]; del Dmin[u]
else: Dmin[u] = min([e[2] for e in D[u]])
print("{0:3d}. dmin={1:3d} node={2:4d}".format(step,dmin,u))
if prLevel<2: print("\n-----\nCore =",Core)
t2 = datetime.datetime.now()
print("\nfinished: ",t2.ctime(),"\ntime used: ", t2-t1)
==== Example: Connectivity ====
[[https://github.com/bavla/Graph/blob/master/JSON/ConnectivityTest.json|ConnectivityTest.json]]
{{tq:pics:g2.png}}
======= RESTART: C:\Users\batagelj\work\Python\graph\graph\CoresTQ.py =======
Temporal cores in: ConnectivityTest.json
started: Tue Sep 20 01:04:16 2016
Deg = {
1: [(1, 9, 1)],
2: [(1, 3, 2), (3, 9, 3)],
3: [(1, 9, 1)],
4: [(1, 3, 2), (3, 9, 3)],
5: [(1, 5, 3), (5, 9, 2)],
6: [(1, 9, 2)],
7: [(1, 5, 4), (5, 7, 3), (7, 9, 4)],
8: [(1, 9, 4)],
9: [(1, 9, 4)],
10: [(1, 9, 4)],
11: [(1, 7, 3), (7, 9, 4)],
12: [(1, 9, 0)],
13: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
14: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
15: [(1, 2, 0), (2, 8, 2), (8, 9, 0)]}
1. dmin= 1 node= 1
2. dmin= 1 node= 2
3. dmin= 1 node= 3
4. dmin= 1 node= 2
5. dmin= 2 node= 4
6. dmin= 2 node= 5
7. dmin= 2 node= 6
8. dmin= 2 node= 13
9. dmin= 2 node= 14
10. dmin= 2 node= 15
11. dmin= 3 node= 7
12. dmin= 3 node= 8
13. dmin= 3 node= 9
14. dmin= 3 node= 10
15. dmin= 3 node= 11
16. dmin= 4 node= 7
17. dmin= 4 node= 8
18. dmin= 4 node= 9
19. dmin= 4 node= 10
20. dmin= 4 node= 11
20. dmin= 4 node= 11
-----
Core = {
1: [(1, 9, 1)],
2: [(1, 9, 1)],
3: [(1, 9, 1)],
4: [(1, 9, 2)],
5: [(1, 9, 2)],
6: [(1, 9, 2)],
7: [(1, 7, 3), (7, 9, 4)],
8: [(1, 7, 3), (7, 9, 4)],
9: [(1, 7, 3), (7, 9, 4)],
10: [(1, 7, 3), (7, 9, 4)],
11: [(1, 7, 3), (7, 9, 4)],
12: [(1, 9, 0)],
13: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
14: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
15: [(1, 2, 0), (2, 8, 2), (8, 9, 0)]}
finished: Tue Sep 20 01:04:16 2016
time used: 0:00:00.120007
>>>
>>> C3 = TQ.TQ.TQdictCut(Core,3)
>>> C3
{
7: [(1, 7, 3), (7, 9, 4)],
8: [(1, 7, 3), (7, 9, 4)],
9: [(1, 7, 3), (7, 9, 4)],
10: [(1, 7, 3), (7, 9, 4)],
11: [(1, 7, 3), (7, 9, 4)]}
>>>
==== Example: Terror 50 ====
======= RESTART: C:/Users/batagelj/work/Python/graph/graph/CoresTQ.py =======
Temporal cores in: Terror news 50.json
started: Sun Sep 18 02:52:06 2016
Deg = {
1: [(1, 2, 5), (2, 3, 6), (3, 4, 3), (4, 5, 5), (5, 6, 4), (6, 8, 3),
(8, 10, 5), (10, 11, 3), (11, 13, 2), (13, 16, 3), (16, 17, 4),
(17, 18, 5), (18, 19, 3), (19, 21, 1), (21, 22, 2), (22, 23, 1),
(23, 24, 4), (24, 25, 1), (25, 29, 3), (29, 31, 2), (31, 33, 3),
(33, 34, 1), (34, 36, 3), (36, 37, 2), (37, 39, 3), (39, 40, 4),
(40, 41, 2), (41, 42, 0), (42, 43, 3), (43, 44, 2), (44, 45, 3),
(45, 46, 1), (46, 47, 2), (47, 48, 3), (48, 49, 0), (49, 50, 4),
(50, 51, 1), (51, 52, 2), (52, 53, 1), (53, 54, 0), (54, 58, 2),
(58, 59, 3), (59, 60, 2), (60, 61, 4), (61, 62, 0), (62, 64, 2),
(64, 65, 1), (65, 67, 2)],
2: [(1, 2, 27), (2, 3, 29), ...
.......
..., (63, 64, 2), (64, 65, 0), (66, 67, 0)],
50: [(1, 2, 3), (2, 3, 2), (3, 5, 1), (5, 8, 0), (8, 10, 1), (10, 11, 2),
(11, 12, 1), (12, 15, 0), (15, 16, 3), (16, 17, 1), (17, 19, 0),
(19, 20, 1), (20, 21, 2), (21, 22, 0), (22, 24, 1), (24, 26, 0),
(26, 27, 2), (27, 28, 0), (28, 29, 1), (29, 31, 0), (31, 32, 1),
(32, 33, 0), (33, 35, 1), (35, 37, 0), (37, 38, 1), (38, 42, 0),
(43, 44, 2), (44, 49, 0), (49, 50, 2), (51, 57, 0), (58, 61, 0),
(61, 62, 1), (62, 67, 0)]}
1. dmin= 1 node= 1
2. dmin= 1 node= 3
3. dmin= 1 node= 4
4. dmin= 1 node= 5
5. dmin= 1 node= 6
...
111. dmin= 1 node= 27
112. dmin= 2 node= 1
...
370. dmin= 2 node= 50
371. dmin= 3 node= 1
...
580. dmin= 3 node= 50
581. dmin= 4 node= 1
...
675. dmin= 4 node= 25
676. dmin= 5 node= 1
677. dmin= 5 node= 4
678. dmin= 5 node= 5
...
705. dmin= 5 node= 4
706. dmin= 5 node= 15
707. dmin= 5 node= 20
708. dmin= 5 node= 36
709. dmin= 5 node= 43
710. dmin= 5 node= 47
-----
Core = {
1: [(1, 2, 4), (2, 3, 5), (3, 5, 3), (5, 6, 4), (6, 8, 3), (8, 10, 4),
(10, 11, 3), (11, 14, 2), (14, 18, 3), (18, 19, 2), (19, 21, 1),
(21, 22, 2), (22, 23, 1), (23, 24, 3), (24, 25, 1), (25, 28, 2),
(28, 29, 3), (29, 33, 2), (33, 34, 1), (34, 38, 2), (38, 39, 3),
(39, 41, 2), (41, 42, 0), (42, 45, 2), (45, 46, 1), (46, 47, 2),
(47, 48, 3), (48, 49, 0), (49, 50, 3), (50, 51, 1), (51, 52, 2),
(52, 53, 1), (53, 54, 0), (54, 57, 2), (57, 58, 1), (58, 59, 2),
(59, 60, 1), (60, 61, 2), (61, 62, 0), (62, 64, 2), (64, 65, 1),
(65, 67, 2)],
2: [(1, 3, 5), (3, 6, 4), (6, 7, 5), ...
.......
... , (63, 64, 1), (64, 65, 0), (66, 67, 0)],
50: [(1, 3, 2), (3, 5, 1), (5, 8, 0), (8, 10, 1), (10, 11, 2), (11, 12, 1),
(12, 15, 0), (15, 16, 3), (16, 17, 1), (17, 19, 0), (19, 20, 1),
(20, 21, 2), (21, 22, 0), (22, 24, 1), (24, 26, 0), (26, 27, 1),
(27, 28, 0), (28, 29, 1), (29, 31, 0), (31, 32, 1), (32, 33, 0),
(33, 35, 1), (35, 37, 0), (37, 38, 1), (38, 42, 0), (43, 44, 1),
(44, 49, 0), (49, 50, 2), (51, 57, 0), (58, 61, 0), (61, 62, 1),
(62, 67, 0)]}
finished: Sun Sep 18 02:52:24 2016
time used: 0:00:17.924025
>>> Core3 = { u: TQ.TQ.cut(core,3) for u, core in Core.items() }
>>> C3 = { u: core for u, core in Core3.items() if core!=[] }
>>> for v in C3: print(v,':',G.getNode(v,'lab'),C3[v])
1 : united_states [(1, 2, 4), (2, 3, 5), (5, 6, 4), (8, 10, 4)]
2 : attack [(1, 3, 5), (3, 6, 4), (6, 7, 5), (7, 10, 4), (11, 12, 4), (30, 31, 4)]
4 : people [(1, 3, 5), (3, 6, 4), (6, 7, 5), (7, 8, 4)]
5 : afghanistan [(1, 3, 4), (5, 6, 4), (6, 7, 5), (8, 10, 4), (30, 31, 4)]
6 : bin_laden [(1, 4, 4), (5, 6, 4), (6, 7, 5), (7, 10, 4), (11, 12, 4)]
7 : new_york [(1, 3, 5), (3, 6, 4), (6, 7, 5), (30, 31, 4)]
8 : pres_bush [(1, 3, 5), (3, 6, 4), (6, 7, 5), (7, 10, 4), (11, 12, 4)]
9 : washington [(1, 3, 5), (3, 6, 4), (6, 7, 5), (7, 10, 4), (11, 12, 4)]
10 : official [(1, 3, 5), (3, 4, 4), (5, 6, 4), (6, 7, 5)]
12 : military [(1, 2, 4), (5, 6, 4), (30, 31, 4)]
13 : plane [(1, 3, 5), (3, 7, 4)]
14 : world_trade_ctr [(1, 3, 5), (3, 6, 4), (6, 7, 5), (30, 31, 4)]
15 : security [(1, 2, 4), (2, 3, 5), (5, 6, 4)]
16 : american [(2, 3, 4)]
17 : country [(1, 3, 4), (5, 10, 4)]
18 : city [(1, 3, 5), (3, 4, 4)]
19 : war [(1, 2, 4), (2, 3, 5), (5, 8, 4)]
20 : tuesday [(1, 3, 5), (3, 7, 4)]
21 : pentagon [(1, 3, 5), (3, 4, 4), (5, 6, 4), (6, 7, 5)]
22 : force [(5, 6, 4)]
23 : government [(1, 3, 4), (5, 6, 4)]
24 : leader [(1, 4, 4), (6, 10, 4)]
25 : world [(1, 3, 5), (3, 10, 4)]
26 : terrorism [(2, 3, 4)]
27 : day [(2, 3, 4), (5, 6, 4)]
28 : week [(5, 6, 4), (6, 7, 5), (8, 10, 4), (11, 12, 4)]
29 : worker [(1, 2, 4), (2, 3, 5)]
30 : office [(1, 3, 4)]
31 : group [(2, 3, 4), (6, 7, 4)]
32 : air [(2, 3, 4), (5, 6, 4)]
34 : time [(1, 3, 5), (3, 4, 4), (5, 6, 4), (7, 8, 4)]
35 : hijack [(2, 3, 4)]
36 : strike [(2, 3, 4), (5, 6, 4), (6, 7, 5), (30, 31, 4)]
38 : flight [(2, 3, 4)]
39 : tell [(2, 3, 4)]
40 : terrorist [(1, 3, 4), (6, 7, 4)]
41 : airport [(2, 3, 4)]
42 : pakistan [(2, 3, 4), (5, 7, 4)]
43 : tower [(1, 3, 5), (3, 4, 4), (6, 7, 5)]
45 : new [(2, 3, 4)]
47 : wednesday [(2, 3, 5), (3, 4, 4), (8, 10, 4)]
48 : nation [(1, 3, 4), (5, 6, 4)]
49 : police [(2, 4, 4), (5, 6, 4)]
>>>
==== Example: Stem cells research in Spain ====
nNodes = 577, nEdges = 8578
======= RESTART: C:\Users\batagelj\work\Python\graph\graph\CoresTQ.py =======
Temporal cores in: stem.json
started: Mon Sep 19 15:22:58 2016
1. dmin= 1 node= 1
11. dmin= 1 node= 21
21. dmin= 1 node= 33
......
1001. dmin= 7 node= 344
1011. dmin= 7 node= 102
1021. dmin= 8 node= 30
......
1851. dmin= 22 node= 5
1861. dmin= 22 node= 58
1871. dmin= 22 node= 192
1881. dmin= 25 node= 16
1891. dmin= 25 node= 76
1901. dmin= 25 node= 336
1902. dmin= 25 node= 403
finished: Mon Sep 19 15:23:00 2016
time used: 0:00:02.435004
>>>
>>> C20 = TQ.TQ.TQdictCut(Core,20)
>>> for v in C20:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C20[v])
2 : HCSC/M [(2010, 2011, 20), (2011, 2012, 21)]
3 : IN/A [(2008, 2009, 25)]
5 : CIC-IBMCC/SA [(2010, 2011, 20), (2011, 2013, 22)]
6 : HUS/SA [(2008, 2009, 25), (2010, 2011, 20), (2011, 2012, 21), (2012, 2013, 22)]
8 : IDIBELL/B [(2011, 2012, 20)]
9 : UB/B [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
10 : UNIZAR/Z [(2008, 2009, 21), (2012, 2013, 21)]
11 : USAL/SA [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
12 : HVH/B [(2010, 2011, 20), (2011, 2013, 22)]
13 : HNJ/M [(2010, 2011, 20), (2012, 2013, 22)]
16 : ICO/CT [(2008, 2009, 25), (2010, 2011, 20), (2012, 2013, 22)]
17 : HMM/MU [(2011, 2012, 22)]
259 : HMS/Z [(2011, 2012, 21)]
20 : UPC/B [(2011, 2012, 21), (2012, 2013, 22)]
21 : ICREA/B [(2010, 2011, 20)]
22 : HDM/B [(2008, 2009, 21), (2012, 2013, 22)]
23 : UNAV [(2008, 2009, 25), (2011, 2013, 22)]
24 : UPV-EHU [(2008, 2009, 21), (2010, 2011, 20)]
27 : HISC3/M [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
543 : PFIZER/M [(2011, 2012, 21)]
32 : HRYC/M [(2008, 2009, 21), (2010, 2011, 20), (2011, 2013, 22)]
289 : HJXXIII/T [(2008, 2009, 25)]
34 : HCL/V [(2010, 2011, 20), (2011, 2013, 22)]
35 : HUGTIP/B [(2010, 2011, 20), (2012, 2013, 20)]
36 : UAB/B [(2008, 2009, 21), (2010, 2011, 20), (2011, 2013, 22)]
37 : US/SE [(2010, 2011, 20)]
38 : UV/V [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
40 : HCL/B [(2010, 2011, 20), (2011, 2013, 22)]
46 : IDIBAPS/B [(2008, 2009, 21), (2010, 2011, 20), (2011, 2013, 22)]
48 : HSCSP/B [(2008, 2009, 21), (2010, 2011, 20), (2011, 2013, 22)]
51 : HBST/B [(2008, 2009, 25), (2011, 2012, 21)]
53 : H12O/M [(2008, 2009, 25), (2011, 2013, 21)]
54 : CNB [(2012, 2013, 22)]
55 : HUPH/M [(2011, 2012, 21), (2012, 2013, 22)]
57 : HCLB/Z [(2011, 2012, 21)]
58 : HCUN/NA [(2011, 2013, 22)]
266 : URL/B [(2012, 2013, 22)]
62 : UAM/M [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
63 : UCM/M [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
65 : HRS/CO [(2012, 2013, 21)]
66 : HCRUCES/BI [(2011, 2012, 21)]
67 : CIPF/V [(2008, 2009, 21)]
69 : UMA/MA [(2008, 2009, 21), (2010, 2011, 20), (2011, 2012, 21), (2012, 2013, 22)]
72 : HUMV/S [(2008, 2009, 25), (2011, 2013, 22)]
73 : UGR/GR [(2011, 2012, 22), (2012, 2013, 20)]
74 : CIBERDEM [(2008, 2009, 25)]
75 : SEHH [(2011, 2012, 21), (2012, 2013, 20)]
76 : HULP/M [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
77 : UPV/V [(2008, 2009, 21)]
336 : TERCEL [(2008, 2009, 25)]
81 : HVA/MU [(2011, 2012, 20), (2012, 2013, 21)]
82 : UM/MU [(2008, 2009, 25)]
85 : UA/A [(2008, 2009, 25), (2011, 2012, 20)]
87 : HUP/M [(2011, 2013, 22)]
344 : HSO/M [(2011, 2012, 21)]
89 : UPF/B [(2008, 2009, 21), (2012, 2013, 22)]
91 : CIBERNED [(2012, 2013, 22)]
92 : GENYO/GR [(2011, 2012, 21)]
93 : CBMSO/M [(2010, 2011, 20), (2011, 2012, 22), (2012, 2013, 21)]
96 : BACM/GR [(2011, 2013, 22)]
272 : ULEON/LE [(2011, 2013, 22)]
310 : SESCAM/TO [(2011, 2012, 21)]
102 : USC [(2011, 2013, 22)]
103 : CIBEROBN [(2011, 2012, 21)]
108 : HGJF/CA [(2011, 2012, 21)]
109 : HVN/GR [(2008, 2009, 21), (2011, 2012, 22), (2012, 2013, 21)]
111 : HANDERSON/M [(2011, 2012, 21)]
112 : INCYL [(2008, 2009, 21), (2010, 2011, 20), (2012, 2013, 21)]
258 : INIA/M [(2012, 2013, 22)]
123 : H-JAEN [(2012, 2013, 22)]
124 : HJC/C [(2011, 2012, 20)]
403 : SERGAS/C [(2008, 2009, 25)]
133 : HCSOL/MA [(2012, 2013, 22)]
134 : IBV/V [(2008, 2009, 25)]
135 : CRG/B [(2008, 2009, 25), (2011, 2012, 21)]
535 : SERIDA/O [(2011, 2012, 21)]
146 : HSC/GR [(2010, 2011, 20)]
147 : HGM/M [(2010, 2011, 20), (2011, 2013, 22)]
149 : IIBM/M [(2011, 2012, 22)]
150 : UNIOVI/O [(2010, 2011, 20)]
153 : UAH/M [(2008, 2009, 25)]
176 : HUVR/SE [(2008, 2009, 25), (2011, 2013, 22)]
186 : UVA [(2012, 2013, 22)]
192 : IRB/B [(2011, 2012, 22)]
452 : HVS/TO [(2011, 2012, 21)]
80 : HUPLFV/V [(2008, 2009, 25), (2010, 2011, 20), (2011, 2013, 22)]
307 : HVB/LE [(2010, 2011, 20)]
232 : HUB/B [(2008, 2009, 25)]
492 : UPNA/NA [(2012, 2013, 22)]
253 : UCLM [(2011, 2012, 21), (2012, 2013, 22)]
>>>
>>> TQ.TQ.maxmin(); coreNum = []
>>> for u in Core: coreNum = TQ.TQ.sum(coreNum,Core[u])
>>> TQ.TQ.combinatorial()
>>> coreNum
[(1997, 1998, 10), (1998, 1999, 15), (1999, 2000, 12), (2000, 2002, 15), (2002, 2003, 13), (2003, 2006, 14),
(2006, 2007, 10), (2007, 2008, 14), (2008, 2009, 25), (2009, 2010, 16), (2010, 2011, 20), (2011, 2013, 22)]
==== Example: Violence ====
======= RESTART: C:\Users\batagelj\work\Python\graph\graph\CoresTQ.py =======
Temporal cores in: violenceE.json
started: Mon Sep 19 16:58:58 2016
1. dmin= 1 node= 1
11. dmin= 1 node= 8
21. dmin= 1 node= 4
31. dmin= 1 node= 1
41. dmin= 1 node= 7
51. dmin= 1 node= 27
61. dmin= 2 node= 7
71. dmin= 2 node= 1
81. dmin= 2 node= 19
91. dmin= 3 node= 8
97. dmin= 3 node= 21
finished: Mon Sep 19 16:58:59 2016
time used: 0:00:00.120000
>>> C3 = TQ.TQ.TQdictCut(Core,3)
>>> for v in C3:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C3[v])
16 : workers [(29, 30, 3), (33, 34, 3), (39, 41, 3)]
1 : undefined [(29, 30, 3), (39, 40, 3)]
2 : ? [(31, 32, 3), (33, 34, 3), (40, 41, 3)]
3 : people [(31, 32, 3), (33, 34, 3), (39, 40, 3)]
4 : police [(31, 32, 3), (33, 34, 3), (40, 41, 3)]
21 : catholics [(33, 34, 3)]
7 : fascists [(29, 30, 3), (31, 32, 3), (33, 34, 3), (39, 41, 3)]
8 : communists [(29, 30, 3)]
10 : socialists [(31, 32, 3), (40, 41, 3)]
>>> C2 = TQ.TQ.TQdictCut(Core,2)
>>> for v in C2:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C2[v])
1 : undefined [(15, 16, 2), (17, 18, 2), (25, 29, 2), (29, 30, 3), (31, 32, 2), (38, 39, 2), (39, 40, 3),
(41, 44, 2), (45, 46, 2), (48, 49, 2)]
2 : ? [(14, 16, 2), (17, 18, 2), (28, 29, 2), (31, 32, 3), (32, 33, 2), (33, 34, 3), (34, 35, 2),
(40, 41, 3)]
3 : people [(16, 18, 2), (23, 24, 2), (25, 26, 2), (28, 30, 2), (31, 32, 3), (33, 34, 3), (35, 37, 2),
(39, 40, 3), (41, 43, 2), (48, 49, 2)]
4 : police [(11, 12, 2), (14, 20, 2), (21, 23, 2), (29, 31, 2), (31, 32, 3), (32, 33, 2), (33, 34, 3),
(34, 37, 2), (38, 40, 2), (40, 41, 3)]
5 : land owners [(15, 16, 2), (17, 20, 2), (29, 30, 2), (36, 37, 2), (38, 40, 2), (42, 43, 2)]
7 : fascists [(11, 12, 2), (16, 17, 2), (19, 20, 2), (21, 24, 2), (25, 29, 2), (29, 30, 3), (30, 31, 2),
(31, 32, 3), (32, 33, 2), (33, 34, 3), (34, 37, 2), (38, 39, 2), (39, 41, 3), (41, 44, 2),
(45, 46, 2), (48, 49, 2)]
8 : communists [(28, 29, 2), (29, 30, 3), (31, 33, 2), (35, 37, 2), (43, 44, 2)]
9 : workers (agr)[(15, 16, 2), (17, 20, 2), (28, 30, 2), (31, 32, 2), (33, 35, 2), (38, 43, 2), (45, 46, 2)]
10 : socialists [(11, 12, 2), (16, 18, 2), (19, 20, 2), (22, 23, 2), (25, 26, 2), (27, 30, 2), (31, 32, 3),
(33, 37, 2), (38, 40, 2), (40, 41, 3), (41, 42, 2)]
12 : war affected [(35, 36, 2), (39, 40, 2)]
13 : protesters [(15, 16, 2), (21, 22, 2), (29, 30, 2), (31, 32, 2), (38, 40, 2)]
16 : workers [(11, 12, 2), (14, 18, 2), (19, 20, 2), (21, 24, 2), (25, 26, 2), (27, 29, 2), (29, 30, 3),
(30, 33, 2), (33, 34, 3), (34, 37, 2), (38, 39, 2), (39, 41, 3), (41, 44, 2), (45, 46, 2)]
17 : the right [(17, 18, 2), (41, 42, 2)]
19 : populars [(41, 42, 2)]
20 : students [(17, 18, 2)]
21 : catholics [(33, 34, 3)]
25 : republicans [(26, 27, 2)]
26 : thugs [(29, 30, 2)]
27 : prisoners/arrested [(40, 41, 2)]
>>>
===== Temporal Ps cores =====
September 20, 2016
gdir = 'c:/users/batagelj/work/python/graph/graph'
wdir = 'c:/users/batagelj/work/python/graph/JSON'
import sys, os, datetime, json
sys.path = [gdir]+sys.path; os.chdir(wdir)
import GraphNew as Graph
import TQ
fJSON = 'ConnectivityWeighted.json'
# fJSON = "violenceE.json"
# fJSON = 'stem.json'
# fJSON = 'Terror news 50.json'
# S = Graph.Graph.loadNetJSON(fJSON); G = S.pairs2edges()
# fJSON = 'ConnectivityTest.json'
# fJSON = 'ExampleB.json'
# fJSON = 'PathfinderTest.json'
G = Graph.Graph.loadNetJSON(fJSON)
G.delLoops()
print("Temporal Ps cores in: ",fJSON)
t1 = datetime.datetime.now()
print("started: ",t1.ctime(),"\n")
Tmin,Tmax = G._graph['time']
D = { u: G.TQnetSum(u) for u in G._nodes }
# print("Sum =",D,"\n")
Core = { u: [d for d in D[u] if d[2]==0] for u in G.nodes() }
# core number = 0
D = { u: [d for d in D[u] if d[2]>0] for u in G.nodes() }
D = { u: d for u,d in D.items() if d!=[] }
Dmin = { u: min([e[2] for e in d]) for u,d in D.items() }
step = 0
while len(D)>0:
step += 1
dmin,u = min( (v,k) for k,v in Dmin.items() )
if step % 10 == 1:
print("{0:3d}. dmin={1:3d} node={2:4d}".format(step,dmin,u))
cCore = TQ.TQ.complement(Core[u],Tmin,Tmax)
core = TQ.TQ.extract(cCore,[d for d in D[u] if d[2] == dmin])
if core!=[]:
Core[u] = TQ.TQ.sum(Core[u],core)
D[u] = TQ.TQ.cutGE(TQ.TQ.sum(D[u],TQ.TQ.minus(core)),dmin)
for link in G.star(u):
v = G.twin(u,link)
if not(v in D): continue
chLink = TQ.TQ.minus(TQ.TQ.extract(core,G.getLink(link,'tq')))
if chLink==[]: continue
diff = TQ.TQ.cutGE(TQ.TQ.sum(D[v],chLink),0)
D[v] = [ (sd,fd,max(vd,dmin)) for sd,fd,vd in diff ]
if len(D[v])==0: del D[v]; del Dmin[v]
else: Dmin[v] = min([e[2] for e in D[v]])
if len(D[u])==0: del D[u]; del Dmin[u]
else: Dmin[u] = min([e[2] for e in D[u]])
print("{0:3d}. dmin={1:3d} node={2:4d}".format(step,dmin,u))
# print("\n-----\nCore =",Core)
t2 = datetime.datetime.now()
print("\nfinished: ",t2.ctime(),"\ntime used: ", t2-t1)
==== Example: Connectivity ====
[[https://github.com/bavla/Graph/blob/master/JSON/ConnectivityTest.json|ConnectivityTest.json]]
====== RESTART: C:/Users/batagelj/work/Python/graph/graph/PsCoresTQ.py ======
Temporal Ps cores in: ConnectivityTest.json
started: Tue Sep 20 19:59:46 2016
1. dmin= 1 node= 1
11. dmin= 3 node= 7
20. dmin= 4 node= 11
finished: Tue Sep 20 19:59:46 2016
time used: 0:00:00.038002
>>> Core
{
1: [(1, 9, 1)],
2: [(1, 9, 1)],
3: [(1, 9, 1)],
4: [(1, 9, 2)],
5: [(1, 9, 2)],
6: [(1, 9, 2)],
7: [(1, 7, 3), (7, 9, 4)],
8: [(1, 7, 3), (7, 9, 4)],
9: [(1, 7, 3), (7, 9, 4)],
10: [(1, 7, 3), (7, 9, 4)],
11: [(1, 7, 3), (7, 9, 4)],
12: [(1, 9, 0)],
13: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
14: [(1, 2, 0), (2, 8, 2), (8, 9, 0)],
15: [(1, 2, 0), (2, 8, 2), (8, 9, 0)]}
We get the same result as with standard temporal core procedure.
==== Example: Weighted connectivity ====
{{tq:pics:connweight.png}}
==== RESTART: C:/Users/batagelj/work/Python/graph/graph/testPsCoresTQ.py ====
Temporal Ps cores in: ConnectivityWeighted.json
started: Tue Sep 20 19:26:25 2016
Sum = {
1: [(1, 5, 3), (5, 9, 5)],
2: [(1, 3, 7), (3, 9, 10)],
3: [(1, 5, 4), (5, 9, 2)],
4: [(1, 3, 4), (3, 9, 7)],
5: [(1, 5, 10), (5, 9, 7)],
6: [(1, 9, 7)],
7: [(1, 5, 13), (5, 7, 10), (7, 9, 14)],
8: [(1, 5, 13), (5, 9, 10)],
9: [(1, 5, 19), (5, 9, 16)],
10: [(1, 9, 11)],
11: [(1, 7, 11), (7, 9, 15)],
12: [(1, 9, 0)],
13: [(1, 2, 0), (2, 5, 6), (5, 8, 9), (8, 9, 0)],
14: [(1, 2, 0), (2, 8, 7), (8, 9, 0)],
15: [(1, 2, 0), (2, 5, 5), (5, 8, 8), (8, 9, 0)]}
D = {
1: [(1, 5, 3), (5, 9, 5)],
2: [(1, 3, 7), (3, 9, 10)],
3: [(1, 5, 4), (5, 9, 2)],
4: [(1, 3, 4), (3, 9, 7)],
5: [(1, 5, 10), (5, 9, 7)],
6: [(1, 9, 7)],
7: [(1, 5, 13), (5, 7, 10), (7, 9, 14)],
8: [(1, 5, 13), (5, 9, 10)],
9: [(1, 5, 19), (5, 9, 16)],
10: [(1, 9, 11)],
11: [(1, 7, 11), (7, 9, 15)],
13: [(2, 5, 6), (5, 8, 9)],
14: [(2, 8, 7)],
15: [(2, 5, 5), (5, 8, 8)]}
Core = {
1: [(1, 5, 3), (5, 9, 5)],
2: [(1, 5, 4), (5, 9, 5)],
3: [(1, 5, 4), (5, 9, 2)],
4: [(1, 5, 4), (5, 9, 5)],
5: [(1, 9, 5)],
6: [(1, 9, 5)],
7: [(1, 9, 10)],
8: [(1, 9, 10)],
9: [(1, 9, 10)],
10: [(1, 9, 10)],
11: [(1, 9, 10)],
12: [(1, 9, 0)],
13: [(1, 2, 0), (2, 5, 5), (5, 8, 7), (8, 9, 0)],
14: [(1, 2, 0), (2, 5, 5), (5, 8, 7), (8, 9, 0)],
15: [(1, 2, 0), (2, 5, 5), (5, 8, 7), (8, 9, 0)]}
==== Example: Violence ====
>>>
====== RESTART: C:/Users/batagelj/work/Python/graph/graph/PsCoresTQ.py ======
Temporal Ps cores in: violenceE.json
started: Tue Sep 20 22:17:14 2016
1. dmin= 1 node= 1
11. dmin= 1 node= 9
21. dmin= 1 node= 19
31. dmin= 2 node= 1
41. dmin= 2 node= 7
51. dmin= 2 node= 25
61. dmin= 3 node= 8
71. dmin= 4 node= 1
81. dmin= 4 node= 19
91. dmin= 5 node= 9
101. dmin= 6 node= 10
111. dmin= 7 node= 7
121. dmin= 8 node= 12
131. dmin= 10 node= 8
141. dmin= 12 node= 8
151. dmin= 15 node= 4
161. dmin= 17 node= 16
171. dmin= 24 node= 7
181. dmin= 30 node= 7
191. dmin= 53 node= 7
201. dmin= 71 node= 16
206. dmin=174 node= 16
finished: Tue Sep 20 22:17:15 2016
time used: 0:00:00.140000
>>> C = TQ.TQ.TQdictCut(Core,10)
>>> for v in C:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C[v])
16 : workers [(1, 2, 27), (10, 11, 11), (14, 15, 27), (16, 17, 11), (17, 18, 17), (18, 19, 12), (22, 23, 17),
(25, 26, 11), (27, 28, 18), (28, 29, 16), (29, 30, 53), (30, 31, 56), (31, 32, 51), (32, 33, 30),
(33, 34, 17), (34, 35, 71), (35, 36, 76), (36, 37, 53), (37, 38, 11), (38, 39, 23), (39, 40, 54),
(40, 41, 13), (41, 42, 174), (42, 43, 25), (43, 44, 20), (45, 46, 15), (46, 47, 25)]
1 : undefined [(25, 26, 11), (27, 28, 12), (28, 29, 16), (41, 42, 133), (45, 46, 11)]
3 : people [(28, 29, 12)]
4 : police [(1, 2, 36), (6, 7, 15), (10, 11, 24), (12, 13, 29), (14, 15, 27), (15, 16, 13), (16, 17, 24),
(17, 18, 17), (18, 19, 12), (22, 23, 17), (31, 32, 17)]
7 : fascists [(25, 26, 11), (27, 28, 30), (28, 29, 31), (29, 30, 64), (30, 31, 56), (31, 32, 51), (32, 33, 30),
(33, 34, 24), (34, 35, 71), (35, 36, 76), (36, 37, 53), (37, 38, 13), (38, 39, 23), (39, 40, 54),
(40, 41, 13), (41, 42, 174), (42, 43, 25), (43, 44, 20), (45, 46, 15), (46, 47, 25)]
8 : communists [(29, 30, 13), (30, 31, 10), (31, 32, 12)]
9 : workers (agr)[(10, 11, 24), (16, 17, 24), (28, 29, 16), (30, 31, 13), (36, 37, 11), (39, 40, 15), (43, 44, 10)]
10 : socialists [(10, 11, 10), (12, 13, 29), (27, 28, 30), (28, 29, 31), (29, 30, 64), (30, 31, 29), (31, 32, 17),
(32, 33, 14), (33, 34, 24), (34, 35, 38), (35, 36, 23), (36, 37, 26), (37, 38, 13), (38, 39, 19),
(39, 40, 54), (45, 46, 13)]
12 : war affected [(1, 2, 36)]
13 : protesters [(6, 7, 15), (15, 16, 13), (16, 17, 20)]
==== Example: Stem ====
>>>
====== RESTART: C:/Users/batagelj/work/Python/graph/graph/PsCoresTQ.py ======
Temporal Ps cores in: stem.json
started: Tue Sep 20 22:37:07 2016
1. dmin= 1 node= 1
11. dmin= 1 node= 21
21. dmin= 1 node= 33
31. dmin= 1 node= 46
......
1721. dmin= 24 node= 64
1731. dmin= 25 node= 10
1741. dmin= 25 node= 134
1751. dmin= 26 node= 55
......
1891. dmin= 38 node= 253
1901. dmin= 41 node= 54
1911. dmin= 41 node= 40
1921. dmin= 46 node= 109
1931. dmin= 55 node= 72
1939. dmin= 55 node= 272
finished: Tue Sep 20 22:37:09 2016
time used: 0:00:02.450003
>>> C = TQ.TQ.TQdictCut(Core,25)
>>> for v in C:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C[v])
6 : HUS/SA [(2008, 2009, 36), (2009, 2010, 26), (2010, 2011, 31), (2011, 2012, 30), (2012, 2013, 38)]
9 : UB/B [(2008, 2009, 36), (2009, 2010, 26), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 39)]
12 : HVH/B [(2008, 2009, 26), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 46), (2012, 2013, 38)]
27 : HISC3/M [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 41)]
32 : HRYC/M [(2008, 2009, 36), (2009, 2010, 25), (2010, 2011, 30), (2011, 2012, 54), (2012, 2013, 41)]
62 : UAM/M [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 39)]
63 : UCM/M [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 41)]
69 : UMA/MA [(2008, 2009, 36), (2009, 2010, 26), (2010, 2011, 30), (2011, 2012, 32), (2012, 2013, 37)]
40 : HCL/B [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 41)]
46 : IDIBAPS/B [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 41)]
48 : HSCSP/B [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 41)]
38 : UV/V [(2008, 2009, 36), (2009, 2011, 30), (2011, 2012, 55), (2012, 2013, 41)]
11 : USAL/SA [(2008, 2009, 36), (2010, 2011, 31), (2011, 2012, 42), (2012, 2013, 38)]
89 : UPF/B [(2008, 2009, 36), (2010, 2011, 25), (2011, 2012, 34), (2012, 2013, 40)]
147 : HGM/M [(2009, 2010, 26), (2010, 2011, 31), (2011, 2012, 42), (2012, 2013, 39)]
176 : HUVR/SE [(2008, 2009, 36), (2010, 2011, 31), (2011, 2012, 55), (2012, 2013, 39)]
23 : UNAV [(2008, 2009, 36), (2009, 2010, 30), (2011, 2012, 54), (2012, 2013, 41)]
34 : HCL/V [(2008, 2009, 25), (2010, 2011, 31), (2011, 2012, 34), (2012, 2013, 38)]
36 : UAB/B [(2008, 2009, 36), (2009, 2011, 30), (2011, 2012, 38), (2012, 2013, 37)]
58 : HCUN/NA [(2008, 2009, 25), (2010, 2011, 28), (2011, 2012, 52), (2012, 2013, 41)]
72 : HUMV/S [(2008, 2009, 36), (2010, 2011, 25), (2011, 2012, 55), (2012, 2013, 41)]
76 : HULP/M [(2008, 2009, 36), (2010, 2011, 31), (2011, 2012, 46), (2012, 2013, 39)]
80 : HUPLFV/V [(2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31), (2011, 2013, 38)]
24 : UPV-EHU [(2008, 2009, 28), (2009, 2010, 30), (2010, 2011, 31)]
13 : HNJ/M [(2008, 2009, 27), (2010, 2011, 30), (2012, 2013, 38)]
16 : ICO/CT [(2008, 2009, 36), (2010, 2011, 31), (2012, 2013, 37)]
51 : HBST/B [(2008, 2009, 25), (2011, 2012, 33), (2012, 2013, 29)]
5 : CIC-IBMCC/SA [(2010, 2011, 30), (2011, 2012, 55), (2012, 2013, 41)]
93 : CBMSO/M [(2010, 2011, 30), (2011, 2012, 44), (2012, 2013, 37)]
109 : HVN/GR [(2008, 2009, 36), (2011, 2012, 46), (2012, 2013, 35)]
112 : INCYL [(2008, 2009, 36), (2010, 2011, 29), (2012, 2013, 32)]
53 : H12O/M [(2008, 2009, 36), (2011, 2012, 33), (2012, 2013, 37)]
55 : HUPH/M [(2010, 2011, 26), (2011, 2012, 34), (2012, 2013, 36)]
2 : HCSC/M [(2010, 2011, 31), (2011, 2012, 32)]
35 : HUGTIP/B [(2010, 2011, 31), (2012, 2013, 32)]
37 : US/SE [(2009, 2010, 30), (2010, 2011, 31)]
67 : CIPF/V [(2008, 2009, 32), (2012, 2013, 32)]
73 : UGR/GR [(2011, 2012, 39), (2012, 2013, 37)]
3 : IN/A [(2008, 2009, 36)]
49 : CMRB/B [(2008, 2009, 28)]
307 : HVB/LE [(2010, 2011, 28)]
54 : CNB [(2012, 2013, 41)]
57 : HCLB/Z [(2011, 2012, 30)]
81 : HVA/MU [(2009, 2010, 30), (2012, 2013, 37)]
82 : UM/MU [(2008, 2009, 36)]
85 : UA/A [(2008, 2009, 25)]
87 : HUP/M [(2011, 2012, 47), (2012, 2013, 41)]
344 : HSO/M [(2011, 2012, 25)]
91 : CIBERNED [(2012, 2013, 38)]
289 : HJXXIII/T [(2008, 2009, 25)]
28 : CT/M [(2010, 2011, 25)]
101 : HGC/CS [(2012, 2013, 27)]
96 : BACM/GR [(2011, 2012, 38), (2012, 2013, 37)]
272 : ULEON/LE [(2011, 2012, 55), (2012, 2013, 41)]
357 : HALC/M [(2010, 2011, 26)]
102 : USC [(2011, 2012, 55), (2012, 2013, 41)]
108 : HGJF/CA [(2011, 2012, 26)]
258 : INIA/M [(2012, 2013, 38)]
124 : HJC/C [(2010, 2011, 30), (2011, 2012, 26)]
10 : UNIZAR/Z [(2008, 2009, 36), (2012, 2013, 25)]
15 : HSD/PM [(2010, 2011, 26), (2012, 2013, 27)]
17 : HMM/MU [(2011, 2012, 38)]
259 : HMS/Z [(2011, 2012, 34)]
20 : UPC/B [(2012, 2013, 29)]
21 : ICREA/B [(2010, 2011, 31)]
22 : HDM/B [(2008, 2009, 36), (2012, 2013, 38)]
403 : SERGAS/C [(2008, 2009, 36)]
405 : HVC/ZA [(2009, 2010, 30)]
133 : HCSOL/MA [(2012, 2013, 38)]
134 : IBV/V [(2008, 2009, 25)]
135 : CRG/B [(2008, 2009, 33)]
535 : SERIDA/O [(2011, 2012, 34)]
146 : HSC/GR [(2010, 2011, 28)]
149 : IIBM/M [(2011, 2012, 50)]
150 : UNIOVI/O [(2009, 2010, 25), (2010, 2011, 31)]
153 : UAH/M [(2008, 2009, 25)]
171 : UJAEN/J [(2010, 2011, 25), (2011, 2012, 27)]
186 : UVA [(2012, 2013, 27)]
192 : IRB/B [(2011, 2012, 38), (2012, 2013, 27)]
266 : URL/B [(2012, 2013, 27)]
65 : HRS/CO [(2012, 2013, 32)]
66 : HCRUCES/BI [(2011, 2012, 27)]
74 : CIBERDEM [(2008, 2009, 25)]
77 : UPV/V [(2008, 2009, 28)]
336 : TERCEL [(2008, 2009, 25)]
232 : HUB/B [(2008, 2009, 36)]
492 : UPNA/NA [(2012, 2013, 37)]
245 : HCAUL/LE [(2011, 2012, 26)]
253 : UCLM [(2011, 2012, 38), (2012, 2013, 32)]
>>>
>>> TQ.TQ.maxmin(); coreNum = []
>>> for u in Core: coreNum = TQ.TQ.sum(coreNum,Core[u])
>>> TQ.TQ.combinatorial()
>>> coreNum
[(1997, 1998, 10), (1998, 1999, 15), (1999, 2000, 12), (2000, 2001, 15), (2001, 2002, 21), (2002, 2003, 13), (2003, 2004, 15),
(2004, 2005, 14), (2005, 2006, 17), (2006, 2007, 14), (2007, 2008, 24), (2008, 2009, 36), (2009, 2010, 30), (2010, 2011, 31),
(2011, 2012, 55), (2012, 2013, 41)]
==== Example: Terror 50 ====
>>>
====== RESTART: C:/Users/batagelj/work/Python/graph/graph/PsCoresTQ.py ======
Temporal Ps cores in: Terror news 50.json
started: Fri Sep 23 00:42:34 2016
1. dmin= 1 node= 1
11. dmin= 1 node= 14
21. dmin= 1 node= 18
31. dmin= 1 node= 26
41. dmin= 1 node= 16
......
811. dmin= 23 node= 28
821. dmin= 29 node= 4
831. dmin= 31 node= 14
841. dmin= 36 node= 2
851. dmin= 47 node= 2
861. dmin= 61 node= 14
finished: Fri Sep 23 00:42:46 2016
time used: 0:00:11.140637
>>> TQ.TQ.maxmin(); coreNum = []
>>> for u in Core: coreNum = TQ.TQ.sum(coreNum,Core[u])
>>> TQ.TQ.combinatorial()
>>> coreNum
[(1, 2, 59), (2, 3, 61), (3, 4, 35), (4, 5, 36), (5, 6, 52), (6, 7, 34), (7, 8, 20), (8, 9, 21), (9, 10, 24),
(10, 11, 21), (11, 12, 23), (12, 13, 12), (13, 14, 8), (14, 15, 12), (15, 16, 13), (16, 17, 12), (17, 18, 15),
(18, 19, 16), (19, 20, 8), (20, 21, 12), (21, 22, 10), (22, 23, 14), (23, 24, 11), (24, 25, 7), (25, 26, 11),
(26, 27, 8), (27, 29, 11), (29, 30, 5), (30, 31, 13), (31, 34, 8), (34, 35, 7), (35, 36, 9), (36, 37, 11),
(37, 38, 8), (38, 39, 4), (39, 40, 9), (40, 41, 10), (41, 42, 12), (42, 43, 7), (43, 44, 4), (44, 47, 5),
(47, 49, 7), (49, 50, 8), (50, 51, 7), (51, 52, 6), (52, 53, 4), (53, 54, 7), (54, 55, 6), (55, 57, 5),
(57, 58, 4), (58, 60, 5), (60, 63, 4), (63, 64, 3), (64, 66, 5), (66, 67, 4)]
>>> C = TQ.TQ.TQdictCut(Core,10)
>>> for v in C:
print("{0:3d} : {1:11s} ".format(v,G.getNode(v,'lab')),C[v])
7 : new_york [(1, 2, 59), (2, 3, 61), (3, 4, 33), (4, 5, 30), (5, 6, 49), (6, 7, 31), (7, 8, 16),
(8, 9, 21), (9, 10, 24), (10, 11, 21), (11, 12, 19), (12, 13, 12), (14, 15, 12),
(15, 16, 13), (16, 17, 12), (17, 18, 15), (18, 19, 16), (20, 21, 12), (21, 22, 10),
(22, 23, 14), (23, 24, 11), (25, 26, 11), (27, 29, 11), (30, 31, 10), (36, 37, 11),
(40, 41, 10), (41, 42, 12)]
9 : washington [(1, 2, 35), (2, 3, 38), (3, 4, 13), (4, 5, 16), (5, 6, 46), (6, 7, 31), (7, 8, 11),
(8, 9, 21), (9, 10, 24), (10, 11, 21), (11, 12, 19), (12, 13, 12), (14, 15, 12),
(15, 16, 13), (16, 18, 12), (18, 19, 16), (20, 21, 12), (21, 22, 10), (22, 23, 12),
(23, 24, 10), (25, 26, 11), (27, 28, 11), (30, 31, 10), (36, 37, 11), (40, 41, 10),
(41, 42, 12)]
2 : attack [(1, 2, 47), (2, 3, 61), (3, 4, 35), (4, 5, 36), (5, 6, 52), (6, 7, 34), (7, 8, 20),
(8, 9, 21), (9, 10, 24), (10, 11, 21), (11, 12, 23), (12, 13, 12), (14, 15, 12),
(15, 16, 13), (16, 17, 12), (17, 18, 15), (18, 19, 16), (22, 23, 14), (23, 24, 11),
(25, 26, 11), (27, 28, 10), (28, 29, 11), (30, 31, 10), (40, 41, 10)]
14 : world_trade_c[(1, 2, 59), (2, 3, 61), (3, 4, 33), (4, 5, 30), (5, 6, 49), (6, 7, 31), (7, 9, 16),
(9, 10, 17), (10, 12, 14), (15, 16, 13), (16, 17, 12), (17, 18, 15), (18, 19, 16),
(22, 23, 14)]
4 : people [(1, 2, 35), (2, 3, 29), (3, 4, 16), (4, 5, 21), (5, 6, 17), (6, 7, 19), (8, 9, 13),
(9, 10, 14), (18, 19, 15)]
5 : afghanistan [(1, 2, 13), (2, 3, 14), (5, 6, 19), (6, 7, 11), (8, 10, 12), (27, 29, 11), (30, 31, 13)]
6 : bin_laden [(1, 2, 13), (2, 3, 14), (3, 4, 12), (5, 6, 19), (6, 7, 15), (8, 10, 12), (18, 19, 16)]
13 : plane [(1, 2, 41), (2, 3, 43), (3, 4, 26), (4, 5, 21), (5, 6, 31), (6, 7, 13), (7, 8, 10)]
28 : week [(5, 6, 25), (6, 8, 20), (8, 9, 21), (9, 10, 24), (10, 11, 20), (11, 12, 23)]
35 : hijack [(1, 2, 12), (2, 3, 17), (3, 4, 12), (5, 6, 13), (17, 18, 10), (18, 19, 11)]
8 : pres_bush [(1, 2, 35), (2, 3, 29), (4, 5, 13), (5, 6, 16), (6, 7, 15), (8, 10, 11)]
43 : tower [(1, 2, 46), (2, 3, 28), (3, 4, 17), (4, 5, 12), (5, 6, 13), (6, 7, 10)]
20 : tuesday [(1, 2, 41), (2, 3, 61), (3, 4, 35), (4, 5, 36), (5, 6, 52), (6, 7, 34)]
21 : pentagon [(1, 2, 46), (2, 3, 29), (3, 4, 17), (4, 5, 12), (5, 6, 18), (6, 7, 15)]
36 : strike [(2, 3, 17), (5, 6, 15), (18, 19, 15), (27, 29, 11), (30, 31, 13)]
1 : united_states[(1, 2, 12), (2, 3, 29), (5, 7, 15), (8, 10, 11), (18, 19, 10)]
40 : terrorist [(1, 2, 36), (2, 3, 17), (5, 6, 13), (27, 28, 10)]
17 : country [(1, 2, 13), (2, 3, 17), (5, 6, 11), (18, 19, 16)]
25 : world [(1, 2, 16), (2, 3, 29), (5, 6, 14), (18, 19, 16)]
19 : war [(1, 2, 12), (2, 3, 29), (5, 7, 15), (8, 10, 11)]
10 : official [(1, 2, 16), (2, 4, 18), (5, 6, 10), (6, 7, 13)]
34 : time [(1, 2, 14), (2, 3, 18), (3, 4, 11)]
48 : nation [(1, 2, 10), (2, 3, 13), (5, 6, 11)]
12 : military [(18, 19, 15), (27, 28, 10)]
47 : wednesday [(2, 3, 29), (8, 10, 11)]
49 : police [(2, 3, 12), (5, 6, 10)]
27 : day [(2, 3, 17), (5, 6, 10)]
15 : security [(2, 3, 13)]
16 : american [(2, 3, 17)]
18 : city [(1, 3, 13)]
22 : force [(5, 6, 11)]
24 : leader [(1, 2, 16)]
29 : worker [(2, 3, 13)]
30 : office [(1, 2, 13)]
31 : group [(2, 3, 17)]
32 : air [(5, 6, 11)]
38 : flight [(2, 3, 17)]
39 : tell [(2, 3, 11)]
42 : pakistan [(5, 6, 11)]
3 : taliban [(2, 3, 11)]