summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/typings/cytoscape/cytoscape.d.ts
blob: 3527281e5e7200c0429c7870d7bace12a8c594ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
// Type definitions for Cytoscape.js 2.4.2
// Project: http://js.cytoscape.org/
// Definitions by:  Fabian Schmidt
//
// Translation from Objects in help to Typescript interface.
// cy   --> Cy.Instance
//  the core
// ele  --> Cy.CollectionFirst
//  a collection of a single element (node or edge)
// eles --> Cy.Collection
//  a collection of one or more elements (nodes and edges)
// node --> Cy.CollectionFirstNode
//  a collection of a single node
// nodes -> Cy.CollectionNodes
//  a collection of one or more nodes
// edge --> Cy.CollectionFirstEdge
//  a collection of a single edge
// edges -> Cy.CollectionEdges
//  a collection of one or more edges
//
// The library makes a diferrence between input and output parameter due to the dynamic behaviour of the Cytoscape library.
// For a input parameter it will always expect:
//  - Cy.Collection
//      The input can be any element (node and edge) collection.
//  - Cy.CollectionNodes
//      The input must be a node collection.
//  - Cy.CollectionEdges
//      The input must be a edge collection.
//  - Cy.CollectionFirst
//      The input must be a single element.
//  - Cy.CollectionFirstNode
//      The inut must be a single node.
//  - Cy.CollectionFirstEdge
//      The input must be a single edge.
//
// For a output of a function it will always give:
//  - Cy.CollectionElements
//      The output is a collection of node and edge elements OR single element.
//  - Cy.CollectionEdges
//      The output is a collection of edge elements OR single edge.
//  - Cy.CollectionNodes
//      The output is a collection of node elements OR single node.

// import {CommonLinkBase} from "../../app/models/graph/graph-links/common-base-link";
// import {CommonNodeBase} from "../../app/models/graph/nodes/base-common-node";
declare module Cy {
    /**
     * See http://js.cytoscape.org/#selectors for details about writing selectors.
     */
    import ClipExtent = d3.geo.ClipExtent;
    type Selector = string;

    /**
     * Possbile values are 'additive' or 'single'.
     */
    type SelectionType = string;

    /**
     * Possible values are 'nodes' or 'edges'.
     */
    type ElementGroup = string;

    /**
     * Possible values are 'x' or 'y'.
     */
    type PositionDimension = string;

    /**
     *
     * Usually temp or nonserialisable data can be stored.
     */
    type Scratchpad = any;

    interface CollectionElements extends CollectionEdges, CollectionNodes, CollectionFirstElement {
        //Intentionally empty.
    }

    interface Extent {
        x1: number, y1: number, x2: number, y2: number, w: number, h: number
    }

    interface CollectionEdges extends Collection, CollectionFirstEdge,
        CollectionEdgesTraversing {
    }

    interface CollectionNodes extends Collection, CollectionFirstNode,
        CollectionNodesMetadata, CollectionNodesPosition, CollectionNodesTraversing, CollectionNodesCompound {
    }

    interface Collection extends CollectionFirst,
        CollectionManipulation, CollectionEvents, CollectionData, CollectionPosition, CollectionLayout, CollectionSelection, CollectionStyle, CollectionAnimation, CollectionComparision, CollectionIteration, CollectionBuildingUnion, CollectionAlgorithms, CollectionTraversing {
    }

    interface CollectionFirstElement extends CollectionFirstEdge, CollectionFirstNode {
        //Intentionally empty.
    }

    interface CollectionFirstEdge extends CollectionFirst,
        CollectionFirstEdgeData, CollectionFirstEdgeTraversing {
    }

    interface CollectionFirstNode extends CollectionFirst,
        CollectionFirstNodeMetadata, CollectionFirstNodePosition, CollectionFirstNodeCompound {
    }

    interface CollectionFirst extends CollectionFirstManipulation, CollectionFirstData, CollectionFirstPosition, CollectionFirstSelection, CollectionFirstStyle, CollectionFirtsAnimation {
    }

    interface CollectionManipulation {
        /**
         * Remove the elements from the graph.
         */
        remove(): CollectionElements;

        /**
         * Put removed elements back into the graph.
         */
        restore(): CollectionElements;

        /**
         * Get a new collection containing clones (i.e. copies) of the elements in the calling collection.
         */
        clone(): CollectionElements;
        /**
         * Get a new collection containing clones (i.e. copies) of the elements in the calling collection.
         */
        copy(): CollectionElements;

        /**
         * Effectively move edges to different nodes. The modified (actually new) elements are returned.
         */
        move(location: { source?: string, target?: string }): CollectionEdges;
        /**
         * Effectively move nodes to different parent node. The modified (actually new) elements are returned.
         */
        move(location: { parent: string }): CollectionNodes;
    }

    interface CollectionEvents {
        //TODO: http://js.cytoscape.org/#collection/events
        //TODO: http://js.cytoscape.org/#collection/events

       // on(event:string, callback: () => void);

        on(events: string, any);
    }

    interface CollectionData {
        //http://js.cytoscape.org/#collection/data

        //    The following fields are immutable:
        //id: The id field is used to uniquely identify an element in the graph.
        //source & target : These fields define an edge's relationship to nodes, and this relationship can not be changed after creation.
        //parent: The parent field defines the parent (compound) node.

        /**
         * Remove developer-defined data associated with the elements.
         */
        removeData(): CollectionElements;
        /**
         * Remove developer-defined data associated with the elements.
         *
         * @param names A space-separated list of fields to delete.
         */
        removeData(names: string): CollectionElements;
        /**
         * Remove developer-defined data associated with the elements.
         */
        removeAttr(): CollectionElements;
        /**
         * Remove developer-defined data associated with the elements.
         *
         * @param names A space-separated list of fields to delete.
         */
        removeAttr(names: string): CollectionElements;

        /**
         * Get an array of the plain JavaScript object representation of all elements in the collection.
         */
        jsons(): string[];
    }
    interface CollectionNodesMetadata {
        //http://js.cytoscape.org/#collection/metadata

        /**
         * Get the maximum degree of the nodes in the collection.
         *
         * For a node, the degree is the number of edge connections it has. Each time a node is referenced as source or target of an edge in the graph, that counts as an edge connection.
         *
         * For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        maxDegree(includeLoops: boolean): number;
        /**
         * Get the minimum indegree of the nodes in the collection.
         *
         * For a node, the indegree is the number of incoming edge connections it has. Each time a node is referred to as target of an edge in the graph, that counts as an incoming edge connection.
         *
         * For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        minIndegree(includeLoops: boolean): number;
        /**
         * Get the maximum indegree of the nodes in the collection.
         *
         * For a node, the indegree is the number of incoming edge connections it has. Each time a node is referred to as target of an edge in the graph, that counts as an incoming edge connection.
         *
         * For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        maxIndegree(includeLoops: boolean): number;
        /**
         * Get the minimum outdegree of the nodes in the collection.
         *
         * For a node, the outdegree is the number of outgoing edge connections it has. Each time a node is referred to as source of an edge in the graph, that counts as an outgoing edge connection.
         *
         * For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        minOutdegree(includeLoops: boolean): number;
        /**
         * Get the maximum outdegree of the nodes in the collection.
         *
         * For a node, the outdegree is the number of outgoing edge connections it has. Each time a node is referred to as source of an edge in the graph, that counts as an outgoing edge connection.
         *
         * For a set of nodes, the the total degree is the total number of edge connections to nodes in the set.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        maxOutdegree(includeLoops: boolean): number;
    }

    interface BoundingBox {
        x1: number;
        x2: number;
        y1: number;
        y2: number;
        w: number;
        h: number;
    }
    interface CollectionPosition {
        //http://js.cytoscape.org/#collection/position--dimensions

        /**
         * Get the bounding box of the elements in model coordinates.
         *
         * @param options An object containing options for the function.
         */
        boundingBox(options: BoundingBoxOptions): BoundingBox;
        /**
         * Get the bounding box of the elements in model coordinates.
         *
         * @param options An object containing options for the function.
         */
        boundingbox(options?: BoundingBoxOptions): BoundingBox;

        /**
         * Get the bounding box of the elements in rendered coordinates.
         *
         * @param options An object containing options for the function.
         */
        renderedBoundingBox(options?: BoundingBoxOptions): BoundingBox;
        /**
         * Get the bounding box of the elements in rendered coordinates.
         *
         * @param options An object containing options for the function.
         */
        renderedBoundingbox(options?: BoundingBoxOptions): BoundingBox;
    }
    interface CollectionNodesPosition {
        //http://js.cytoscape.org/#collection/position--dimensions

        /**
         * Set the positions functionally.
         *
         * @param callback A callback function that returns the position to set for each element.
         * i - The index of the element when iterating over the elements in the collection.
         * ele - The element being iterated over for which the function should return a position to set.
         */
        positions(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
        /**
         * Set positions for all nodes based on a single position object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        positions(pos: Position): CollectionNodes;

        /**
         * Set the positions functionally.
         *
         * @param callback A callback function that returns the position to set for each element.
         * i - The index of the element when iterating over the elements in the collection.
         * ele - The element being iterated over for which the function should return a position to set.
         */
        modelPositions(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
        /**
         * Set positions for all nodes based on a single position object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        modelPositions(pos: Position): CollectionNodes;

        /**
         * Set the positions functionally.
         *
         * @param callback A callback function that returns the position to set for each element.
         * i - The index of the element when iterating over the elements in the collection.
         * ele - The element being iterated over for which the function should return a position to set.
         */
        points(callback: (i: number, ele: CollectionNodes) => Position): CollectionNodes;
        /**
         * Set positions for all nodes based on a single position object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        points(pos: Position): CollectionNodes;

        /**
         * Allow the user to grab the nodes.
         */
        grabify(): CollectionNodes;

        /**
         * Disallow the user to grab the nodes.
         */
        ungrabify(): CollectionNodes;

        /**
         * Lock the nodes such that their positions can not be changed.
         */
        lock(): CollectionNodes;
        /**
         * Unlock the nodes such that their positions can be changed.
         */
        unlock(): CollectionNodes;
    }
    interface CollectionLayout {
        // http://js.cytoscape.org/#collection/layout

        /**
         * Run a layout on the elements in the calling collection, algorithmically positioning the nodes.
         * This function is useful for running a layout on a subset of the elements in the graph.
         *
         * @param options The layout options.
         */
        layout(options: LayoutOptions): CollectionElements;

        /**
         * Get a new layout, which can be used to algorithmically position the nodes in the collection.
         * This function is useful for running a layout on a subset of the elements in the graph, perhaps in parallel to other layouts.
         *
         * You must specify options.name with the name of the layout you wish to use.
         *
         * Note: that you must call layout.run() in order for it to affect the graph.
         *
         * @param options The layout options.
         */
        makeLayout(options: LayoutOptions): LayoutInstance;
        /**
         * Get a new layout, which can be used to algorithmically position the nodes in the collection.
         * This function is useful for running a layout on a subset of the elements in the graph, perhaps in parallel to other layouts.
         *
         * You must specify options.name with the name of the layout you wish to use.
         *
         * Note: that you must call layout.run() in order for it to affect the graph.
         *
         * @param options The layout options.
         */
        createLayout(options: LayoutOptions): LayoutInstance;
    }
    interface CollectionSelection {
        // http://js.cytoscape.org/#collection/selection

        /**
         * Make the elements selected (NB other elements outside the collection are not affected).
         */
        select(): CollectionElements;

        /**
         * Make the elements not selected (NB other elements outside the collection are not affected).
         */
        unselect(): CollectionElements;
        /**
         * Make the elements not selected (NB other elements outside the collection are not affected).
         */
        deselect(): CollectionElements;

        /**
         * Make the selection states of the elements mutable.
         */
        selectify(): CollectionElements;

        /**
         * Make the selection states of the elements immutable.
         */
        unselectify(): CollectionElements;
    }
    interface CollectionStyle {
        // http://js.cytoscape.org/#collection/style

        /**
         * Add classes to elements.
         *
         * @param classes A space-separated list of class names to add to the elements.
         */
        addClass(classes: string): CollectionElements;

        /**
         * Remove classes from elements.
         *
         * @param classes A space-separated list of class names to remove from the elements.
         */
        removeClass(classes: string): CollectionElements;

        /**
         * Toggle whether the elements have the specified classes.
         *
         * @param classes A space-separated list of class names to toggle on the elements.
         * @param toggle [optional] Instead of automatically toggling, adds the classes on truthy values or removes them on falsey values.
         */
        toggleClass(classes: string, toggle?: boolean): CollectionElements;

        /**
         * Add classes to the elements, and then remove the classes after a specified duration.
         *
         * @param classes A space-separated list of class names to flash on the elements.
         * @param duration [optional] The duration in milliseconds that the classes should be added on the elements. After the duration, the classes are removed.
         */
        flashClass(classes: string, duration?: number): CollectionElements;


        /**
         * Get a name-value pair object containing visual style properties and their values for the element.
         */
        style(): Css.ElementCss;
        /**
         * Get a particular style property value.
         *
         * @param name The name of the visual style property to get.
         */
        style(name: string): Css.ElementCss;

        /**
         * Get a name-value pair object containing visual style properties and their values for the element.
         */
        css(): Css.ElementCss;
        /**
         * Get a particular style property value.
         *
         * @param name The name of the visual style property to get.
         */
        css(name: string): Css.ElementCss;

        /**
         * Get a name-value pair object containing visual style properties and their values for the element.
         */
        bypass(): Css.ElementCss;
        /**
         * Get a particular style property value.
         *
         * @param name The name of the visual style property to get.
         */
        bypass(name: string): Css.ElementCss;


        /**
         * Set the specified visual style property for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param name The name of the property to set.
         * @param value The value to set to the visual style property.
         */
        style(name: string, value: string): CollectionElements;
        /**
         * Set several visual style properties at once for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param props An object with name-value pairs representing properties to set on the elements.
         */
        style(props: Css.ElementCss): CollectionElements;

        /**
         * Set the specified visual style property for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param name The name of the property to set.
         * @param value The value to set to the visual style property.
         */
        css(name: string, value: string): CollectionElements;
        /**
         * Set several visual style properties at once for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param props An object with name-value pairs representing properties to set on the elements.
         */
        css(props: Css.ElementCss): CollectionElements;

        /**
         * Set the specified visual style property for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param name The name of the property to set.
         * @param value The value to set to the visual style property.
         */
        bypass(name: string, value: string): CollectionElements;
        /**
         * Set several visual style properties at once for the elements.
         *
         * You should use this function very sparingly, because it overrides the style of an element, despite the state and classes that it has. In general, it's much better to specify a better stylesheet at initialisation that reflects your application state rather than programmatically modifying style.
         *
         * If you would like to remove a particular overridden style property, set null to it.
         *
         * @param props An object with name-value pairs representing properties to set on the elements.
         */
        bypass(props: Css.ElementCss): CollectionElements;

        /**
         * Removes all overridden style of the elements.
         */
        removeStyle(): CollectionElements;
        /**
         * Removes particular overridden style properties of the elements.
         *
         * @param names A space-separated list of property names for which overridden styles will be removed.
         */
        removeStyle(names: string): CollectionElements;
        /**
         * Removes all overridden style of the elements.
         */
        removeCss(): CollectionElements;
        /**
         * Removes particular overridden style properties of the elements.
         *
         * @param names A space-separated list of property names for which overridden styles will be removed.
         */
        removeCss(names: string): CollectionElements;
        /**
         * Removes all overridden style of the elements.
         */
        removeBypass(): CollectionElements;
        /**
         * Removes particular overridden style properties of the elements.
         *
         * @param names A space-separated list of property names for which overridden styles will be removed.
         */
        removeBypass(names: string): CollectionElements;
    }
    interface CollectionAnimation {
        // http://js.cytoscape.org/#collection/animation

        /**
         * Animate the elements.
         *
         * Note that you can specify only one of position and renderedPosition: You can not animate to two positions at once.
         *
         * @param anis An object containing the details of the animation.
         * position - A position to which the elements will be animated.
         * renderedPosition - A rendered position to which the elements will be  animated.
         * style - An object containing name-value pairs of style properties to animate.
         * @param options An object containing animation options.
         * duration - The duration of the animation in milliseconds.
         * queue - A boolean indicating whether to queue the animation.
         * complete - A function to call when the animation is done.
         * step - A function to call each time the animation steps.
         */
        animate(anis: {
            postion?: Position,
            renderedPosition?: Position,
            style?: Css.ElementCss
        }, options?: {
            duration?: number,
            queue?: boolean,
            complete?: () => void,
            step?: () => void
        }): CollectionElements;

        /**
         * Add a delay between animations for the elements.
         *
         * @param duration How long the delay should be in milliseconds.
         * @param complete A function to call when the delay is complete.
         */
        delay(duration: number, complete?: () => void): CollectionElements;

        /**
         * Stop all animations that are currently running.
         *
         * @param clearQueue A boolean, indicating whether the queue of animations should be emptied.
         * @param jumpToEnd A boolean, indicating whether the currently-running animations should jump to their ends rather than just stopping midway.
         */
        stop(clearQueue?: boolean, jumpToEnd?: boolean): CollectionElements;

        /**
         * Remove all queued animations for the elements.
         */
        clearQueue(): CollectionElements;
    }
    interface CollectionComparision {
        // http://js.cytoscape.org/#collection/comparison

        /**
         * Determine whether this collection contains exactly the same elements as another collection.
         *
         * @param eles The other elements to compare to.
         */
        same(eles: Collection): boolean;

        /**
         * Determine whether this collection contains any of the same elements as another collection.
         *
         * @param eles The other elements to compare to.
         */
        anySame(eles: Collection): boolean;

        /**
         * Determine whether all elements in the specified collection are in the neighbourhood of the calling collection.
         *
         * @param eles The other elements to compare to.
         */
        allAreNeighbors(eles: Collection): boolean;
        /**
         * Determine whether all elements in the specified collection are in the neighbourhood of the calling collection.
         *
         * @param eles The other elements to compare to.
         */
        allAreNeighbours(eles: Collection): boolean;

        /**
         * Determine whether any element in this collection matches a selector.
         *
         * @param selector The selector to match against.
         */
        is(selector: Selector): boolean;

        /**
         * Determine whether all elements in the collection match a selector.
         * @param selector The selector to match against.
         */
        allAre(selector: Selector): boolean;

        /**
         * Determine whether any element in this collection satisfies the specified test function.
         *
         * @param test The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being tested.
         * @param thisArg [optional] The value for this within the test function.
         */
        some(test: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): boolean;

        /**
         * Determine whether all elements in this collection satisfy the specified test function.
         *
         * @param test The test function that returns truthy values for elements that satisfy the test and falsey values for elements that do not satisfy the test.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being tested.
         * @param thisArg [optional] The value for this within the test function.
         */
        every(test: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): boolean;
    }
    interface CollectionIteration {
        // http://js.cytoscape.org/#collection/iteration

        /**
         * Get the number of elements in the collection.
         */
        size(): number;
        /**
         * Get the number of elements in the collection.
         */
        length: number;

        /**
         * Get whether the collection is empty, meaning it has no elements.
         */
        empty(): boolean;
        /**
         * Get whether the collection is nonempty, meaning it has elements.
         */
        nonempty(): boolean;

        /**
         * Iterate over the elements in the collection.
         *
         * Note that although this function is convenient in some cases, it is less efficient than making your own loop.
         *
         * @param each The function executed each iteration.
         * i - The index of the element in the collection.
         * ele - The element at the current index.
         */
        each(each: (i: number, ele: CollectionElements) => void);

        /**
         * Iterate over the elements in the collection using an implementation like the native array function namesake.
         *
         * This function behaves like Array.prototype.forEach() with minor changes for convenience:
         * You can exit the iteration early by returning false in the iterating function. The Array.prototype.forEach() implementation does not support this, but it is included anyway on account of its utility.
         *
         * @param each The function executed each iteration.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being iterated.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        forEach(each: (ele: CollectionElements, i: number, eles: CollectionElements) => void|boolean, thisArg?: any);

        /**
         * Get an element at a particular index in the collection.
         *
         * You may use eles[i] in place of eles.eq(i) as a more performant alternative.
         *
         * @param index The index of the element to get.
         */
        eq(index: number): CollectionElements;
        /**
         * Get an element at a particular index in the collection.
         *
         * @param index The index of the element to get.
         */
        [index: number]: CollectionElements;
        /**
         * Get the first element in the collection.
         */
        first(): CollectionElements;
        /**
         * Get the last element in the collection.
         */
        last(): CollectionElements;

        /**
         * Get a subset of the elements in the collection based on specified indices.
         *
         * @param start [optional] An integer that specifies where to start the selection. The first element has an index of 0. Use negative numbers to select from the end of an array.
         * @param end [optional] An integer that specifies where to end the selection. If omitted, all elements from the start position and to the end of the array will be selected. Use negative numbers to select from the end of an array.
         */
        slice(start?: number, end?: number): CollectionElements;
    }
    interface CollectionBuildingUnion {
        /**
         * Get a new collection, resulting from adding the collection with another one
         *
         * @param eles The elements to add.
         */
        (eles: Collection): CollectionElements;
        /**
         * Get a new collection, resulting from adding the collection with another one
         *
         * @param elesArray An array of elements to add.
         */
        (elesArray: Collection[]): CollectionElements;
        /**
         * Get a new collection, resulting from adding the collection with another one
         *
         * @param selector Elements in the graph matching this selector are added.
         */
        (selector: Selector): CollectionElements;
    }
    interface CollectionBuildingDifference {
        /**
         * Get a new collection, resulting from the collection without some specified elements.
         *
         * @param eles The elements that will not be in the resultant collection.
         */
        (eles: Collection): CollectionElements;
        /**
         * Get a new collection, resulting from the collection without some specified elements.
         *
         * @param selector Elements from the calling collection matching this selector will not be in the resultant collection.
         */
        (selector: Selector): CollectionElements;
    }
    interface CollectionBuildingIntersection {
        /**
         * Get the elements in both this collection and another specified collection.
         *
         * @param eles The elements to intersect with.
         */
        (eles: Collection): CollectionElements;
        /**
         * Get the elements in both this collection and another specified collection.
         *
         * @param selector A selector representing the elements to intersect with. All elements in the graph matching the selector are used as the passed collection.
         */
        (selector: Selector): CollectionElements;
    }
    interface CollectionSymmetricDifference {
        /**
         * Get the elements that are in the calling collection or the passed collection but not in both.
         *
         * @param eles The elements to apply the symmetric difference with.
         */
        (eles: Collection): CollectionElements;
        /**
         * Get the elements that are in the calling collection or the passed collection but not in both.
         *
         * @param selector A selector representing the elements to apply the symmetric difference with. All elements in the graph matching the selector are used as the passed collection.
         */
        (selector: Selector): CollectionElements;
    }
    interface CollectionBuildingUnion {
        // http://js.cytoscape.org/#collection/building--filtering

        union: CollectionBuildingUnion;
        //[index: "u"]: CollectionBuildingUnion;
        add: CollectionBuildingUnion;
        //[index: "+"]: CollectionBuildingUnion;
        or: CollectionBuildingUnion;
        //[index: "|"]: CollectionBuildingUnion;

        difference: CollectionBuildingDifference;
        //[index: "\\"]: CollectionBuildingDifference;
        not: CollectionBuildingDifference;
        //[index: "!"]: CollectionBuildingDifference;
        relativeComplement(): CollectionBuildingDifference;
        //[index: "-"]: CollectionBuildingDifference;

        /**
         * Get all elements in the graph that are not in the calling collection.
         */
        absoluteComplement(): CollectionElements;
        /**
         * Get all elements in the graph that are not in the calling collection.
         */
        abscomp(): CollectionElements;
        /**
         * Get all elements in the graph that are not in the calling collection.
         */
        complement(): CollectionElements;

        intersection: CollectionBuildingIntersection;
        intersect: CollectionBuildingIntersection;
        and: CollectionBuildingIntersection;
        //[index: "n"]: CollectionBuildingIntersection;
        //[index: "&"]: CollectionBuildingIntersection;
        //[index: "."]: CollectionBuildingIntersection;

        symmetricDifference: CollectionSymmetricDifference;
        symdiff: CollectionSymmetricDifference;
        xor: CollectionSymmetricDifference;
        //[index: "^"]: CollectionSymmetricDifference;
        //[index: "(+)"]: CollectionSymmetricDifference;
        //[index: "(-)"]: CollectionSymmetricDifference;

        //[index: string]: CollectionBuildingDifference |CollectionBuildingUnion | CollectionBuildingIntersection | CollectionSymmetricDifference;

        /**
         * Perform a traditional left/right diff on the two collections.
         *
         * @param eles The elements on the right side of the diff.
         */
        diff(eles: Collection): CollectionElements;
        /**
         * Perform a traditional left/right diff on the two collections.
         *
         * @param selector A selector representing the elements on the right side of the diff. All elements in the graph matching the selector are used as the passed collection.
         * @return This function returns a plain object of the form { left, right, both } where
         * left - is the set of elements only in the calling (i.e. left) collection,
         * right - is the set of elements only in the passed (i.e. right) collection, and
         * both - is the set of elements in both collections.
         */
        diff(selector: Selector): {
            left: CollectionElements,
            right: CollectionElements,
            both: CollectionElements
        };

        /**
         * Get a new collection containing elements that are accepted by the specified filter.
         *
         * @param selector The selector to match against.
         */
        filter(selector: Selector): CollectionElements;
        /**
         * Get a new collection containing elements that are accepted by the specified filter.
         *
         * @filter selector The filter function that returns true for elements to include.
         * i - The index of the current element being considered.
         * ele - The element being considered.
         */
        filter(filter: (i: number, ele: CollectionElements) => boolean): CollectionElements;
        /**
         * Get the nodes that match the specified selector.
         *
         * @param selector The selector to match against.
         */
        nodes(selector: Selector): CollectionNodes;
        /**
         * Get the edges that match the specified selector.
         *
         * @param selector The selector to match against.
         */
        edges(selector: Selector): CollectionEdges;

        /**
         * Get a new collection containing elements that are accepted by the specified filter, using an implementation like the standard array namesake.
         *
         * @param filter The filter function that returns truthy values for elements to include and falsey values for elements to exclude.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being filtered.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        filterFn(filter: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): CollectionElements;
        /**
         * Get a new collection containing elements that are accepted by the specified filter, using an implementation like the standard array namesake.
         *
         * @param filter The filter function that returns truthy values for elements to include and falsey values for elements to exclude.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being filtered.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        fnFilter(filter: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): CollectionElements;
        /**
         * Get a new collection containing elements that are accepted by the specified filter, using an implementation like the standard array namesake.
         *
         * @param filter The filter function that returns truthy values for elements to include and falsey values for elements to exclude.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being filtered.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        stdFilter(filter: (ele: CollectionElements, i: number, eles: CollectionElements) => boolean, thisArg?: any): CollectionElements;

        /**
         * Get a new collection containing the elements sorted by the specified comparison function.
         *
         * @param sort The sorting comparison function that returns a negative number for ele1 before ele2, 0 for ele1 same as ele2, or a positive number for ele1 after ele2.
         */
        sort(sort: (ele1: CollectionElements, ele2: CollectionElements) => number): CollectionElements;

        /**
         * Get an array containing values mapped from the collection.
         *
         * @param fn The function that returns the mapped value for each element.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being mapped.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        map(fn: (ele: CollectionElements, i: number, eles: CollectionElements) => any, thisArg?: any): any[];

        /**
         * Find a minimum value in a collection.
         *
         * @param fn The function that returns the value to compare for each element.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being mapped.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        min(fn: (ele: CollectionElements, i: number, eles: CollectionElements) => any, thisArg?: any): {
            /**
             * The minimum value found.
             */
            value: any,
            /**
             * The element that corresponds to the minimum value.
             */
            ele: CollectionElements
        };

        /**
         * Find a maximum value and the corresponding element.
         *
         * @param fn The function that returns the value to compare for each element.
         * ele - The current element.
         * i - The index of the current element.
         * eles - The collection of elements being mapped.
         * @param thisArg [optional] The value for this within the iterating function.
         */
        max(fn: (ele: CollectionElements, i: number, eles: CollectionElements) => any, thisArg?: any): {
            /**
             * The maximum value found.
             */
            value: any,
            /**
             * The element that corresponds to the maximum value.
             */
            ele: CollectionElements
        };
    }
    interface CollectionTraversing {
        // http://js.cytoscape.org/#collection/traversing

        /**
         * Get the open neighbourhood of the elements.
         *
         * The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility.
         * An open neighbourhood is one that does not include the original set of elements. If unspecified, a neighbourhood is open by default.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        neighborhood(selector?: Selector): CollectionElements;
        /**
         * Get the open neighbourhood of the elements.
         *
         * The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility.
         * An open neighbourhood is one that does not include the original set of elements. If unspecified, a neighbourhood is open by default.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        openNeighborhood(selector?: Selector): CollectionElements;
        /**
         * Get the closed neighbourhood of the elements.
         *
         * The neighbourhood returned by this function is a bit different than the traditional definition of a "neighbourhood": This returned neighbourhood includes the edges connecting the collection to the neighbourhood. This gives you more flexibility.
         * A closed neighbourhood is one that does include the original set of elements.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        closedNeighborhood(selector?: Selector): CollectionElements;
    }
    interface CollectionEdgesTraversing {
        // http://js.cytoscape.org/#collection/traversing

        /**
         * Get the nodes connected to the edges in the collection
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        connectedNodes(selector?: Selector): CollectionNodes;

        /**
         * Get source nodes connected to the edges in the collection.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        sources(selector?: Selector): CollectionNodes;

        /**
         * Get target nodes connected to the edges in the collection.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        targets(selector?: Selector): CollectionNodes;

        /**
         * Get edges parallel to those in the collection.
         *
         * Two edges are said to be parallel if they connect the same two nodes. Any two parallel edges may connect nodes in the same direction, in which case the edges share the same source and target. They may alternatively connect nodes in the opposite direction, in which case the source and target are reversed in the second edge.
         * That is:
         * - edge1.source().id() === edge2.source().id()
         *   && edge1.target().id() === edge2.target().id()
         * OR
         * - edge1.source().id() === edge2.target().id()
         *   && edge1.target().id() === edge2.source().id()
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        parallelEdges(selector?: Selector): CollectionEdges;

        /**
         * Get edges codirected to those in the collection.
         *
         * Two edges are said to be codirected if they connect the same two nodes in the same direction: The edges have the same source and target.
         * That is:
         * - edge1.source().id() === edge2.source().id()
         *   && edge1.target().id() === edge2.target().id()

         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        codirectedEdges(selector?: Selector): CollectionEdges;
    }
    interface CollectionNodesTraversing {
        // http://js.cytoscape.org/#collection/traversing

        /**
         * Get the edges connecting the collection to another collection. Direction of the edges does not matter.
         *
         * @param eles The other collection.
         */
        edgesWith(eles: Collection): CollectionEdges;
        /**
         * Get the edges connecting the collection to another collection. Direction of the edges does not matter.
         *
         * @param selector The other collection, specified as a selector which is matched against all elements in the graph.
         */
        edgesWith(selector: Selector): CollectionEdges;

        /**
         * Get the edges coming from the collection (i.e. the source) going to another collection (i.e. the target).
         *
         * @param eles The other collection.
         */
        edgesTo(eles: Collection): CollectionEdges;
        /**
         * Get the edges coming from the collection (i.e. the source) going to another collection (i.e. the target).
         *
         * @param selector The other collection, specified as a selector which is matched against all elements in the graph.
         */
        edgesTo(selector: Selector): CollectionEdges;

        /**
         * Get the edges connected to the nodes in the collection.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        connectedEdges(selector?: Selector): CollectionEdges;

        /**
         * From the set of calling nodes, get the nodes which are leaves (i.e. no outgoing edges, as in a directed acyclic graph).
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        leaves(selector?: Selector): CollectionNodes;

        /**
         * Get edges (and their targets) coming out of the nodes in the collection.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        outgoers(selector?: Selector): CollectionEdges;

        /**
         * Recursively get edges (and their targets) coming out of the nodes in the collection (i.e. the outgoers, the outgoers' outgoers, ...).
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        successors(selector?: Selector): CollectionEdges;

        /**
         * Get edges (and their sources) coming into the nodes in the collection.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        incomers(selector?: Selector): CollectionEdges;

        /**
         * Recursively get edges (and their sources) coming into the nodes in the collection (i.e. the incomers, the incomers' incomers, ...).
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        predecessors(selector?: Selector): CollectionEdges;
    }
    interface SearchBreadthFirstOptions {
        /**
         * The root nodes (selector or collection) to start the search from.
         */
        roots: Selector|Collection;
        /**
         * A handler function that is called when a node is visited in the search. The handler returns true when it finds the desired node, and it returns false to cancel the search.
         * i - The index indicating this node is the ith visited node.
         * depth - How many edge hops away this node is from the root nodes.
         * v - The current node.
         * e - The edge connecting the previous node to the current node.
         * u - The previous node.
         */
        visit?: (i: number, depth: number, v: CollectionNodes, e: CollectionEdges, u: CollectionNodes) => boolean;
        /**
         * A boolean indicating whether the algorithm should only go along edges from source to target (default false).
         */
        directed?: boolean;
    }
    interface SearchBreadthFirstResult {
        /**
         * The path of the search.
         * - The path returned includes edges such that if path[i] is a node, then path[i - 1] is the edge used to get to that node.
         */
        path: CollectionElements;
        /**
         * The node found by the search
         * - If no node was found, then found is empty.
         * - If your handler function returns false, then the only the path up to that point is returned.
         */
        found: CollectionNodes;
    }
    interface SearchDijkstraOptions {
        /**
         * The root node (selector or collection) where the algorithm starts.
         */
        root: Selector|Collection;

        /**
         * A function that returns the positive numeric weight for this edge.
         *
         * If no weight function is defined, a constant weight of 1 is used for each edge.
         */
        weight?: (edge: CollectionEdges) => number;

        /**
         * A boolean indicating whether the algorithm should only go along edges from source to target (default false).
         */
        directed?: boolean;
    }
    interface SearchDijkstraResult {
        /**
         * Returns the distance from the source node to node.
         */
        distanceTo: (node: CollectionFirstNode) => number;

        /**
         * Returns a collection containing the shortest path from the source node to node.
         * The path starts with the source node and includes the edges between the nodes in the path such that if pathTo(node)[i] is an edge, then pathTo(node)[i-1] is the previous node in the path and pathTo(node)[i+1] is the next node in the path.
         */
        pathTo: (node: CollectionFirstNode) => Collection;
    }
    interface SearchAStarOptions {
    }
    interface SearchAStarResult {
    }
    interface CollectionAlgorithms {
        // http://js.cytoscape.org/#collection/algorithms

        /**
         * Perform a breadth-first search within the elements in the collection.
         *
         * Note that this function performs a breadth-first search on only the subset of the graph in the calling collection.
         */
        breadthFirstSearch(options: SearchBreadthFirstOptions): SearchBreadthFirstResult;
        /**
         * Perform a breadth-first search within the elements in the collection.
         *
         * Note that this function performs a breadth-first search on only the subset of the graph in the calling collection.
         *
         * @param roots The root nodes (selector or collection) to start the search from.
         * @param visit [optional] A handler function that is called when a node is visited in the search. The handler returns true when it finds the desired node, and it returns false to cancel the search.
         * i - The index indicating this node is the ith visited node.
         * depth - How many edge hops away this node is from the root nodes.
         * v - The current node.
         * e - The edge connecting the previous node to the current node.
         * u - The previous node.
         * @param directed [optional] A boolean indicating whether the search should only go along edges from source to target (default false).
         */
        breadthFirstSearch(roots: Selector|Collection,
                           visit?: (i: number, depth: number, v: CollectionNodes, e: CollectionEdges, u: CollectionNodes) => boolean,
                           directed?: boolean): SearchBreadthFirstResult;
        /**
         * Perform a breadth-first search within the elements in the collection.
         *
         * Note that this function performs a breadth-first search on only the subset of the graph in the calling collection.
         */
        bfs(options: SearchBreadthFirstOptions): SearchBreadthFirstResult;
        /**
         * Perform a breadth-first search within the elements in the collection.
         *
         * Note that this function performs a breadth-first search on only the subset of the graph in the calling collection.
         *
         * @param roots The root nodes (selector or collection) to start the search from.
         * @param visit [optional] A handler function that is called when a node is visited in the search. The handler returns true when it finds the desired node, and it returns false to cancel the search.
         * i - The index indicating this node is the ith visited node.
         * depth - How many edge hops away this node is from the root nodes.
         * v - The current node.
         * e - The edge connecting the previous node to the current node.
         * u - The previous node.
         * @param directed [optional] A boolean indicating whether the search should only go along edges from source to target (default false).
         */
        bfs(roots: Selector|Collection,
            visit?: (i: number, depth: number, v: CollectionNodes, e: CollectionEdges, u: CollectionNodes) => boolean,
            directed?: boolean): SearchBreadthFirstResult;

        /**
         * Perform a depth-first search within the elements in the collection.
         *
         * Note that this function performs a depth-first search on only the subset of the graph in the calling collection.
         */
        depthFirstSearch(options: SearchBreadthFirstOptions): SearchBreadthFirstResult;
        /**
         * Perform a depth-first search within the elements in the collection.
         *
         * Note that this function performs a depth-first search on only the subset of the graph in the calling collection.
         *
         * @param roots The root nodes (selector or collection) to start the search from.
         * @param visit [optional] A handler function that is called when a node is visited in the search. The handler returns true when it finds the desired node, and it returns false to cancel the search.
         * i - The index indicating this node is the ith visited node.
         * depth - How many edge hops away this node is from the root nodes.
         * v - The current node.
         * e - The edge connecting the previous node to the current node.
         * u - The previous node.
         * @param directed [optional] A boolean indicating whether the search should only go along edges from source to target (default false).
         */
        depthFirstSearch(roots: Selector|Collection,
                         visit?: (i: number, depth: number, v: CollectionNodes, e: CollectionEdges, u: CollectionNodes) => boolean,
                         directed?: boolean): SearchBreadthFirstResult;
        /**
         * Perform a depth-first search within the elements in the collection.
         *
         * Note that this function performs a depth-first search on only the subset of the graph in the calling collection.
         */
        dfs(options: SearchBreadthFirstOptions): SearchBreadthFirstResult;
        /**
         * Perform a depth-first search within the elements in the collection.
         *
         * Note that this function performs a depth-first search on only the subset of the graph in the calling collection.
         *
         * @param roots The root nodes (selector or collection) to start the search from.
         * @param visit [optional] A handler function that is called when a node is visited in the search. The handler returns true when it finds the desired node, and it returns false to cancel the search.
         * i - The index indicating this node is the ith visited node.
         * depth - How many edge hops away this node is from the root nodes.
         * v - The current node.
         * e - The edge connecting the previous node to the current node.
         * u - The previous node.
         * @param directed [optional] A boolean indicating whether the search should only go along edges from source to target (default false).
         */
        dfs(roots: Selector|Collection,
            visit?: (i: number, depth: number, v: CollectionNodes, e: CollectionEdges, u: CollectionNodes) => boolean,
            directed?: boolean): SearchBreadthFirstResult;

        /**
         * Perform Dijkstra's algorithm on the elements in the collection. This finds the shortest paths to all other nodes in the collection from the root node.
         *
         * Note that this function performs Dijkstra's algorithm on only the subset of the graph in the calling collection.
         */
        dijkstra(options: SearchDijkstraOptions): SearchDijkstraResult;
        /**
         * Perform Dijkstra's algorithm on the elements in the collection. This finds the shortest paths to all other nodes in the collection from the root node.
         *
         * Note that this function performs Dijkstra's algorithm on only the subset of the graph in the calling collection.
         *
         * @param root The root node (selector or collection) where the algorithm starts.
         * @param weight [optional] A function that returns the positive numeric weight for this edge.
         * If no weight function is defined, a constant weight of 1 is used for each edge.
         * @param directed [optional] A boolean indicating whether the algorithm should only go along edges from source to target (default false).
         */
        dijkstra(root: Selector|Collection,
                 weight?: (edge: CollectionEdges) => number,
                 directed?: boolean): SearchDijkstraResult;


        //TODO: continue here: http://js.cytoscape.org/#collection/algorithms/eles.dijkstra
    }
    interface CollectionNodesCompound {
        // http://js.cytoscape.org/#collection/compound-nodes

        /**
         * Get the compound parent node of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        parent(selector?: Selector): CollectionNodes;

        /**
         * Get all compound ancestor nodes (i.e. parents, parents' parents, etc.) of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        parents(selector?: Selector): CollectionNodes;
        /**
         * Get all compound ancestor nodes (i.e. parents, parents' parents, etc.) of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        ancestors(selector?: Selector): CollectionNodes;

        /**
         * Get all compound ancestors common to all the nodes in the collection, starting with the closest and getting progressively farther.
         *
         * You can get the closest common ancestor via
         *   nodes.commonAncestors().first()
         * and the farthest via
         *   nodes.commonAncestors().last()
         * , because the common ancestors are in descending order of closeness.
         *
         * @param selector [optional] A selector used to filter the resultant collection
         */
        commonAncestors(selector?: Selector): CollectionNodes;

        /**
         * Get all orphan (i.e. has no compound parent) nodes in the calling collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        orphans(selector?: Selector): CollectionNodes;

        /**
         * Get all nonorphan (i.e. has a compound parent) nodes in the calling collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        nonorphans(selector?: Selector): CollectionNodes;

        /**
         * Get all compound child (i.e. direct descendant) nodes of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        children(selector?: Selector): CollectionNodes;

        /**
         * Get all compound descendant (i.e. children, children's children, etc.) nodes of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        descendants(selector?: Selector): CollectionNodes;

        /**
         * Get all sibling (i.e. same compound parent) nodes of each node in the collection.
         *
         * @param selector [optional] A selector used to filter the resultant collection.
         */
        siblings(selector?: Selector): CollectionNodes;
    }

    interface CollectionFirstManipulation {
        /**
         * Get whether the element has been removed from the graph.
         */
        removed(): boolean;
        /**
         * Get whether the element is inside the graph (i.e. not removed).
         */
        inside(): boolean;

    }
    interface CollectionFirstData {
        //http://js.cytoscape.org/#collection/data

        /**
         * Get all data for the element.
         */
        data(): any;
        /**
         * Get a particular data field for the element.
         */
        data(name: string): any;
        /**
         * Set a particular data field for the element.
         */
        data(name: string, value: any);
        /**
         * Update multiple data fields at once via an object.
         */
        data(obj: any);

        /**
         * Get the entire scratchpad object for the element, where temporary or non-JSON data can be stored. App-level scratchpad data should use namespaces prefixed with underscore, like '_foo'.
         */
        scratch(): Scratchpad;
        /**
         * Get the scratchpad at a particular namespace, where temporary or non-JSON data can be stored. App-level scratchpad data should use namespaces prefixed with underscore, like '_foo'.
         *
         * @param namespace A namespace string.
         */
        scratch(namespace: string): Scratchpad;
        /**
         * Set the scratchpad at a particular namespace, where temporary or non-JSON data can be stored. App-level scratchpad data should use namespaces prefixed with underscore, like '_foo'.
         *
         * @param namespace A namespace string.
         * @param value The value to set at the specified namespace.
         */
        scratch(namespace: string, value: any): Scratchpad;

        /**
         * Remove scratchpad data. You should remove scratchpad data only at your own namespaces.
         *
         * @param namespace A namespace string.
         */
        removeScratch(namespace: string);

        /**
         * A shortcut to get the ID of an element.
         */
        id(): string;

        /**
         * Get the element's plain JavaScript object representation.
         */
        json(): string;

        /**
         * Get the group string that defines the type of the element.
         *
         * The group strings are 'nodes' for nodes and 'edges' for edges. In general, you should be using ele.isEdge() and ele.isNode() instead of ele.group().
         */
        group(): ElementGroup;

        /**
         * Get whether the element is a node.
         */
        isNode(): boolean;

        /**
         * Get whether the element is an edge.
         */
        isEdge(): boolean;


        cy(): Cy.Instance
    }
    interface CollectionFirstEdgeData {
        //http://js.cytoscape.org/#collection/data

        /**
         * Get whether the edge is a loop (i.e. source same as target).
         */
        isLoop(): boolean;

        /**
         * Get whether the edge is simple (i.e. source different than target).
         */
        isSimple(): boolean;
    }
    interface CollectionFirstNodeMetadata {
        //http://js.cytoscape.org/#collection/metadata

        /**
         * Get the degree of a node.
         *
         * For a node, the degree is the number of edge connections it has. Each time a node is referenced as source or target of an edge in the graph, that counts as an edge connection.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        degree(includeLoops: boolean): number;
        /**
         * Get the indegree of a node.
         *
         * For a node, the indegree is the number of incoming edge connections it has. Each time a node is referred to as target of an edge in the graph, that counts as an incoming edge connection.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        indegree(includeLoops: boolean): number;
        /***
         * Get the outdegree of a node.
         *
         * For a node, the outdegree is the number of outgoing edge connections it has. Each time a node is referred to as source of an edge in the graph, that counts as an outgoing edge connection.
         *
         * @param includeLoops A boolean, indicating whether loops are to be included in degree calculations.
         */
        outdegree(includeLoops: boolean): number;
    }
    interface CollectionFirstNodePosition extends CollectionPosition{
        //http://js.cytoscape.org/#collection/position--dimensions

        /**
         * Get the (model) position of a node.
         */
        position(): Position;
        /**
         * Get the value of a specified position dimension.
         *
         * @param dimension The position dimension to get.
         */
        position(dimension: PositionDimension): Position;
        /**
         * Set the value of a specified position dimension.
         *
         * @param dimension The position dimension to set.
         * @param value The value to set to the dimension.
         */
        position(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        position(pos: Position): CollectionNodes;

        /**
         * Get the (model) position of a node.
         */
        modelPosition(): Position;
        /**
         * Get the value of a specified position dimension.
         *
         * @param dimension The position dimension to get.
         */
        modelPosition(dimension: PositionDimension): Position;
        /**
         * Set the value of a specified position dimension.
         *
         * @param dimension The position dimension to set.
         * @param value The value to set to the dimension.
         */
        modelPosition(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        modelPosition(pos: Position): CollectionNodes;

        /**
         * Get the (model) position of a node.
         */
        point(): Position;
        /**
         * Get the value of a specified position dimension.
         *
         * @param dimension The position dimension to get.
         */
        point(dimension: PositionDimension): Position;
        /**
         * Set the value of a specified position dimension.
         *
         * @param dimension The position dimension to set.
         * @param value The value to set to the dimension.
         */
        point(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        point(pos: Position): CollectionNodes;

        /**
         * Get the rendered (on-screen) position of a node.
         */
        renderedPosition(): Position;
        /**
         * Get the value of a specified rendered posisition dimension.
         *
         * @param dimension The position dimension to get.
         */
        renderedPosition(dimension: PositionDimension): number;
        /**
         * Set the value of a specified rendered posisition dimension.
         *
         * @param dimension The position dimension to get.
         * @param value The value to set to the dimension.
         */
        renderedPosition(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the rendered position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        renderedPosition(pos: Position): CollectionNodes;

        /**
         * Get the rendered (on-screen) position of a node.
         */
        renderedPoint(): Position;
        /**
         * Get the rendered (on-screen) position of a node.
         *
         * @param dimension The position dimension to get.
         */
        renderedPoint(dimension: PositionDimension): number;
        /**
         * Set the value of a specified rendered posisition dimension.
         *
         * @param dimension The position dimension to get.
         * @param value The value to set to the dimension.
         */
        renderedPoint(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the rendered position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        renderedPoint(pos: Position): CollectionNodes;

        /**
         * Get the position of a node, relative to its compound parent.
         */
        relativePosition(): Position;
        /**
         * Get the position of a node, relative to its compound parent.
         *
         * @param dimension The position dimension to get.
         */
        relativePosition(dimension: PositionDimension): number;
        /**
         * Set the value of a specified relative posisition dimension.
         *
         * @param dimension The position dimension to get.
         * @param value The value to set to the dimension.
         */
        relativePosition(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the relative position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        relativePosition(pos: Position): CollectionNodes;

        /**
         * Get the position of a node, relative to its compound parent.
         */
        relativePoint(): Position;
        /**
         * Get the position of a node, relative to its compound parent.
         *
         * @param dimension The position dimension to get.
         */
        relativePoint(dimension: PositionDimension): number;
        /**
         * Set the value of a specified relative posisition dimension.
         *
         * @param dimension The position dimension to get.
         * @param value The value to set to the dimension.
         */
        relativePoint(dimension: PositionDimension, value: number): CollectionNodes;
        /**
         * Set the relative position using name-value pairs in the specified object.
         *
         * @param pos An object specifying name-value pairs representing dimensions to set.
         */
        relativePoint(pos: Position): CollectionNodes;
    }
    interface CollectionFirstPosition {
        //http://js.cytoscape.org/#collection/position--dimensions

        /**
         * Get the width of the element.
         */
        width(): number;
        /**
         * Get the outer width of the element (includes width & border).
         */
        outerWidth(): number;
        /**
         * Get the width of the element in rendered dimensions.
         */
        renderedWidth(): number;
        /**
         * Get the outer width of the element (includes width & border) in rendered dimensions.
         */
        renderedOuterWidth(): number;

        /**
         * Get the height of the element.
         */
        height(): number;
        /**
         * Get the outer height of the element (includes height & border).
         */
        outerHeight(): number;
        /**
         * Get the height of the element in rendered dimensions.
         */
        renderedHeight(): number;
        /**
         * Get the outer height of the element (includes height & border) in rendered dimensions.
         */
        renderedOuterHeight(): number;

        /**
         * Gets whether the element is active (e.g. on user tap, grab, etc).
         */
        active(): boolean;
    }
    interface CollectionFirstSelection {
        // http://js.cytoscape.org/#collection/selection

        /**
         * Get whether the element is selected.
         */
        selected(): boolean;

        /**
         * Get whether the element's selection state is mutable.
         */
        selectable(): boolean;
    }
    interface CollectionFirstStyle {
        // http://js.cytoscape.org/#collection/style

        /**
         * Get whether an element has a particular class.
         *
         * @param className The name of the class to test for.
         */
        hasClass(className: string): boolean;

        ///**
        //* Get a name-value pair object containing visual style properties and their values for the element.
        //*/
        //style(): Css.ElementCss;
        ///**
        // * Get a particular style property value.
        // *
        // * @param name The name of the visual style property to get.
        // */
        //style(name: string): Css.ElementCss;

        ///**
        // * Get a name-value pair object containing visual style properties and their values for the element.
        // */
        //css(): Css.ElementCss;
        ///**
        // * Get a particular style property value.
        // *
        // * @param name The name of the visual style property to get.
        // */
        //css(name: string): Css.ElementCss;

        ///**
        // * Get a name-value pair object containing visual style properties and their values for the element.
        // */
        //bypass(): Css.ElementCss;
        ///**
        // * Get a particular style property value.
        // *
        // * @param name The name of the visual style property to get.
        // */
        //bypass(name: string): Css.ElementCss;

        /**
         * Get a name-value pair object containing rendered visual style properties and their values for the element.
         */
        renderedStyle(): Css.ElementCss;
        /**
         * Get a particular rendered style property value.
         *
         * @param name The name of the visual style property to get.
         */
        renderedStyle(name: string): Css.ElementCss;
        /**
         * Get a name-value pair object containing rendered visual style properties and their values for the element.
         */
        renderedCss(): Css.ElementCss;
        /**
         * Get a particular rendered style property value.
         *
         * @param name The name of the visual style property to get.
         */
        renderedCss(name: string): Css.ElementCss;

        /**
         * Get whether the element is visible.
         */
        visible(): boolean;
        /**
         * Get whether the element is hidden.
         */
        hidden(): boolean;

        /**
         * Get the effective opacity of the element (i.e. on-screen opacity), which takes into consideration parent node opacity.
         */
        effectiveOpacity(): number;

        /**
         * Get whether the element's effective opacity is completely transparent, which takes into consideration parent node opacity.
         */
        transparent(): boolean;
    }
    interface CollectionFirtsAnimation {
        // http://js.cytoscape.org/#collection/animation

        /**
         * Get whether the element is currently being animated.
         */
        animated(): boolean;
    }
    interface CollectionFirstEdgeTraversing {
        // http://js.cytoscape.org/#collection/traversing

        /**
         * Get source node of this edge.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        source(selector?: Selector): CollectionNodes;

        /**
         * Get target node of this edge.
         *
         * @param selector [optional] An optional selector that is used to filter the resultant collection.
         */
        target(selector?: Selector): CollectionNodes;
    }
    interface CollectionFirstNodeCompound {
        // http://js.cytoscape.org/#collection/compound-nodes

        /**
         * Get whether the node is a compound parent (i.e. a node containing one or more child nodes)
         */
        isParent(): boolean;

        /**
         * Get whether the node is a compound child (i.e. contained within a node)
         */
        isChild(): boolean;
    }

    interface ElementsDefinition {
        nodes: any[];
        edges: any[];
    }

    interface ElementDefinition {


        group?: ElementGroup;
        data:  any;
        /**
         * Scratchpad data (usually temp or nonserialisable data)
         */
        scatch?: Scratchpad;
        /**
         * The model position of the node (optional on init, mandatory after)
         */
        position?: Position;
        /**
         * can alternatively specify position in rendered on-screen pixels
         */
        renderedPosition?: Position;
        /**
         * Whether the element is selected (default false)
         */
        selected?: boolean;
        /**
         * Whether the selection state is mutable (default true)
         */
        selectable?: boolean;
        /**
         * When locked a node's position is immutable (default false)
         */
        locked?: boolean;
        /**
         * Wether the node can be grabbed and moved by the user
         */
        grabbable?: boolean;
        /**
         * a space separated list of class names that the element has
         */
        classes?: string;
        style?: CSSStyleDeclaration;
        /**
         * you should only use `style`/`css` for very special cases; use classes instead
         */
        css?: Css.ElementCss;
    }

    // interface ElementDataDefinition {
    //     /**
    //      * elided id => autogenerated id
    //      */
    //     isSdcElement?: boolean;
    //     id?: string;
    //     position?: Position;
    //     label?: string;
    // }
    interface EdgeDefinition extends ElementDefinition {
        data: any;
    }

    // interface EdgeDataDefinition extends ElementDataDefinition { /**
    //          * the source node id (edge comes from this node)
    //          */
    //         source: string;
    //     /**
    //      * the target node id (edge goes to this node)
    //      */
    //     target: string;
    //     commonGraphLink?: Sdc.Models.CompositionCiLinkBase; //this is sdc-link-data-object
    // }
    interface NodeDefinition extends ElementDefinition {

        data: any;

    }
    // interface NodeDataDefinition extends ElementDataDefinition {
    //     parent?: string;
    //     commonGraphNode?: Sdc.Models.Graph.CommonNodeBase; //this is sdc-node-data-object
    //     type: string
    //
    // }

    interface Stylesheet {
        selector: string;
        css: Css.ElementCss;
    }

    export module Css {
        //TODO: http://js.cytoscape.org/#style

        type Colour = string;

        // TODO: How to constrain to a value?
        type Shape = string; // 'rectangle', 'roundrectangle', 'ellipse', 'triangle', pentagon, hexagon, heptagon, octagon, star

        // TODO: How to constrain to a value?
        type Style = string; // solid, dotted, dashed, or double

        export interface NodeCss {
            width?: number;
            height?: number;
            shape?: Shape;
            backgroundColor?: Colour;
            "background-color"?: any;
            "background-blacken"?: number;
            "background-opacity"?: number;
            "background-image"?: any;
            "background-width"?: number;
            "background-height"?: number;
            "border-width"?: number;
            "border-style"?: Style;
            "border-color"?: Colour;
            "border-opacity"?: number;
            "label"?: string;
            "events"?: string;
            "text-events"?: string;
            "text-valign"? :string;
            "text-halign"? :string;
            "text-margin-y"? :any;
            "active-bg-size"?: number;
            "background-fit"?: string;
            "background-clip"?: string;
            "background-image-opacity"?: number;
            "overlay-color"?: string;
            "font-size"? :number;
            "font-family"? :string;
            "background-position-x"? :number;
            "background-position-y"? :number;
            'overlay-opacity'?: number;
            'text-border-width'?: number;
            'text-border-color'?: string;
            'text-border-opacity'?: number;
        }

        export interface SelectionBox {
            "selection-box-color"?: string
            "selection-box-border-color"?: string
            "selection-box-border-width"?: number
            "selection-box-opacity"?: number

        }

        export interface CompoundNodeCss extends NodeCss {
            "padding-left"?: number;
            "padding-right"?: number;
            "padding-top"?: number;
            "padding-bottom"?: number;
            "compound-sizing-wrt-labels"?: string;
        }

        export interface EdgeCss {

            "line-color"?: string;
            "target-arrow-color"?: string;
            "target-arrow-shape"?: string;
            "curve-style"?: string;
            "control-point-step-size"?: number;
            "control-point-distances"?: string,
            "control-point-weights"?: string,
            "segment-distances"?: string,
            "segment-weights"?: string
            "line-style"? : string
        }

        export interface ElementCss extends NodeCss, CompoundNodeCss, EdgeCss, SelectionBox {
        }
        //export interface ElementCss extends CSSStyleDeclaration { }
    }

    interface Renderer {
        /**
         * The name of the renderer to use. By default, the 'canvas' renderer is used. If you build and register your own renderer, then you can specify its name here.
         */
        name: string;
    }

    interface Instance extends InstanceEvent, InstanceViewPort, InstanceAnimation, InstanceLayout, InstanceStyle, InstanceExport {
        /**
         * Add elements to the graph and return them.
         */
        add(eleObj: ElementDefinition): CollectionElements;
        /**
         * Add elements to the graph and return them.
         */
        add(eleObjs: ElementDefinition[]): CollectionElements;
        /**
         * Add elements to the graph and return them.
         */
        add(eles: Collection): CollectionElements;

        /**
         * Remove elements from the graph and return them.
         */
        remove(eles: Collection): CollectionElements;
        /**
         * Remove elements in the graph matching the specified selector.
         */
        remove(selector: Selector): CollectionElements;

        /**
         * Get an empty collection.
         */
        collection(): CollectionElements;
        /**
         * Get a collection from elements in the graph matching the specified selector.
         */
        collection(selector: Selector): CollectionElements;
        /**
         * Get a collection from an array of elements.
         */
        collection(elesArray: CollectionElements[]): CollectionElements;

        /**
         * Get an element from its ID in a very performant way.
         */
        getElementById(id: string): CollectionElements;

        /**
         * Get elements in the graph matching the specified selector.
         */
        $(selector: Selector): CollectionElements;
        /**
         * Get elements in the graph.
         */
        elements(): CollectionElements;
        /**
         * Get elements in the graph matching the specified selector.
         */
        elements(selector: Selector): CollectionElements;
        /**
         * Get nodes in the graph.
         */
        nodes(): CollectionNodes;
        /**
         * Get nodes in the graph matching the specified selector.
         */
        nodes(selector: Selector): CollectionNodes;
        /**
         * Get edges in the graph.
         */
        edges(): CollectionEdges;
        /**
         * Get edges in the graph matching the specified selector.
         */
        edges(selector: Selector): CollectionEdges;
        /**
         * Get elements in the graph matching the specified selector.
         */
        filter(selector: Selector): CollectionElements;
        /**
         * Get elements in the graph matching the specified filter function.
         */
        filter(filter: (i: number, ele: CollectionFirst) => boolean): CollectionElements;

        /**
         * Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
         *
         *  A callback within which you can make batch updates to elements.
         */
        batch(callback: () => void): void;
        /**
         * Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
         * Starts batching manually (useful for asynchronous cases).
         */
        startBatch(): void;
        /**
         * Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
         * Ends batching manually (useful for asynchronous cases).
         */
        endBatch(): void;

        /**
         * A convenience function to explicitly destroy the instance.
         */
        destroy(): void;

        scratch(namespace?:string): any;
        removeScratch(namespace:string):void;
    }

    interface EventObject {
        /**
         * Holds a reference to the originator of the event (core or element)
         */
        cyTarget: any; //CollectionElements or Cy.Instance;
        data: any;
    }

    interface InstanceEvent {
        // http://js.cytoscape.org/#core/events

        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         */
        on(events: string, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         */
        on(events: string, selector: Selector, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        on(events: string, selector: Selector, data: any, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param eventsMap A map of event names to handler functions.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        on(eventsMap: {
            [value: string]: (evt: EventObject, data?: any) => void
        }, selector?: Selector, data?: any);

        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         */
        bind(events: string, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         */
        bind(events: string, selector: Selector, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        bind(events: string, selector: Selector, data: any, handler: (evt: EventObject, data?: any) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param eventsMap A map of event names to handler functions.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        bind(eventsMap: {
            [value: string]: (evt: EventObject, data?: any) => void
        }, selector?: Selector, data?: any);

        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         */
        listen(events: string, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         */
        listen(events: string, selector: Selector, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        listen(events: string, selector: Selector, data: any, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param eventsMap A map of event names to handler functions.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        listen(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector, data?: any);

        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         */
        addListener(events: string, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         */
        addListener(events: string, selector: Selector, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        addListener(events: string, selector: Selector, data: any, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph.
         *
         * @param eventsMap A map of event names to handler functions.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        addListener(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector, data?: any);

        /**
         * Bind to events that occur in the graph, and trigger the handler only once.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         */
        one(events: string, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph, and trigger the handler only once.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         */
        one(events: string, selector: Selector, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph, and trigger the handler only once.
         *
         * @param events A space separated list of event names.
         * @param handler The handler function that is called when one of the specified events occurs.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        one(events: string, selector: Selector, data: any, handler: (evt: EventObject) => void): void;
        /**
         * Bind to events that occur in the graph, and trigger the handler only once.
         *
         * @param eventsMap A map of event names to handler functions.
         * @param selector A selector to specify elements for which the handler is triggered.
         * @param data A plain object which is passed to the handler in the event object argument.
         */
        one(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector, data?: any);

        /**
         * Remove event handlers.
         * @param events A space separated list of event names.
         * @param selector [optional] The same selector used to bind to the events.
         * @param handler [optional] A reference to the handler function to remove.
         */
        off(events: string, selector?: Selector, handler?: (evt: EventObject) => void): void;

        /**
         * Remove event handlers.
         * @param eventsMap A map of event names to handler functions to remove.
         * @param selector [optional] The same selector used to bind to the events.
         */
        off(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector): void;

        /**
         * Remove event handlers.
         * @param events A space separated list of event names.
         * @param selector [optional] The same selector used to bind to the events.
         * @param handler [optional] A reference to the handler function to remove.
         */
        unbind(events: string, selector?: Selector, handler?: (evt: EventObject) => void): void;

        /**
         * Remove event handlers.
         * @param eventsMap A map of event names to handler functions to remove.
         * @param selector [optional] The same selector used to bind to the events.
         */
        unbind(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector): void;

        /**
         * Remove event handlers.
         * @param events A space separated list of event names.
         * @param selector [optional] The same selector used to bind to the events.
         * @param handler [optional] A reference to the handler function to remove.
         */
        unlisten(events: string, selector?: Selector, handler?: (evt: EventObject) => void): void;

        /**
         * Remove event handlers.
         * @param eventsMap A map of event names to handler functions to remove.
         * @param selector [optional] The same selector used to bind to the events.
         */
        unlisten(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector): void;

        /**
         * Remove event handlers.
         * @param events A space separated list of event names.
         * @param selector [optional] The same selector used to bind to the events.
         * @param handler [optional] A reference to the handler function to remove.
         */
        removeListener(events: string, selector?: Selector, handler?: (evt: EventObject) => void): void;

        /**
         * Remove event handlers.
         *
         * @param eventsMap A map of event names to handler functions to remove.
         * @param selector [optional] The same selector used to bind to the events.
         */
        removeListener(eventsMap: {
            [value: string]: (evt: EventObject) => void
        }, selector?: Selector): void;

        /**
         * Trigger one or more events.
         *
         * @param events A space separated list of event names to trigger.
         * @param extraParams [optional] An array of additional parameters to pass to the handler.
         */
        trigger(events: string, extraParams?: any[]): void;

        /**
         * Trigger one or more events.
         *
         * @param events A space separated list of event names to trigger.
         * @param extraParams [optional] An array of additional parameters to pass to the handler.
         */
        emit(events: string, extraParams?: any[]): void;

        /**
         * Get whether the initial render event has occurred (useful for plugins etc).
         *
         * This function returns whether the initrender event has occurred on the graph, meaning that the renderer has drawn the graph at least once. This is useful when you need to grab image data from the core, as this function will let you know whether that data is available yet: You can not grab the graph scene if it has not yet been rendered.
         */
        initrender(): boolean;

        /**
         * Run a handler function every time a frame is rendered.
         *
         * @param handler The handler function to call on each frame.
         */
        onRender(handler: () => void): void;

        /**
         * Remove handlers function bound via cy.onRender().
         *
         * @param handler [optional] A reference to the handler function to remove. All handlers are removed if this is unspecified.
         */
        offRender(handler?: () => void): void;

        /**
         * Run a callback as soon as the graph becomes ready. If the graph is already ready, then the callback is called immediately.
         * @param fn The callback run as soon as the graph is ready, inside which this refers to the core (cy).
         */
        ready(fn: () => void): void;
    }

    interface InstanceViewPort {
        // http://js.cytoscape.org/#core/viewport-manipulation

        /**
         * Pan the graph to the centre of a collection.
         *
         * @param eles The collection to centre upon.
         */
        center(eles?: Collection): CollectionElements;

        /**
         * Pan and zooms the graph to fit to a collection.
         *
         * @param eles [optional] The collection to fit to.
         * @param padding [optional] An amount of padding (in pixels) to have around the graph
         */
        fit(eles?: Collection, padding?: number): CollectionElements;

        /**
         * Reset the graph to the default zoom level and panning position.
         */
        reset(): CollectionElements;

        /**
         * Get the panning position of the graph.
         */
        pan(): Position;

        /**
         * Set the panning position of the graph.
         *
         * @param renderedPosition The rendered position to pan the graph to.
         */
        pan(renderedPosition?: Position): void;

        /**
         * Relatively pan the graph by a specified rendered position vector.
         *
         * @param renderedPosition The rendered position vector to pan the graph by.
         */
        panBy(renderedPosition: Position): void;

        /**
         * Get whether panning is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
         */
        panningEnabled(): boolean;

        /**
         * Set whether panning is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
         *
         * @param bool A truthy value enables panning; a falsey value disables it.
         */
        panningEnabled(bool: boolean): void;

        /**
         * Get whether panning by user events (e.g. dragging the graph background) is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
         */
        userPanningEnabled(): boolean;

        /**
         * Set whether panning by user events (e.g. dragging the graph background) is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
         *
         * @param bool A truthy value enables user panning; a falsey value disables it.
         */
        userPanningEnabled(bool: boolean): void;

        /**
         * Get the zoom level.
         */
        zoom(): number;
        /**
         * Set the zoom level.
         *
         * @param level The zoom level to set.
         */
        zoom(level: number): void;
        /**
         * Set the zoom level.
         *
         * @param options The options for zooming.
         */
        zoom(options: ZoomOptions): void;

        /**
         * Get whether zooming is enabled.
         */
        zoomingEnabled(): boolean;
        /**
         * Set whether zooming is enabled.
         *
         * @param bool A truthy value enables zooming; a falsey value disables it.
         */
        zoomingEnabled(bool: boolean): void;

        /**
         * Get whether zooming by user events (e.g. mouse wheel, pinch-to-zoom) is enabled.
         */
        userZoomingEnabled(): boolean;
        /**
         * Set whether zooming by user events (e.g. mouse wheel, pinch-to-zoom) is enabled.
         *
         * @param bool A truthy value enables user zooming; a falsey value disables it.
         */
        userZoomingEnabled(bool: boolean): void;

        /**
         * Get the minimum zoom level.
         */
        minZoom(): number;
        /**
         * Set the minimum zoom level.
         *
         * @param zoom The new minimum zoom level to use.
         */
        minZoom(zoom: number): void;

        /**
         * Get the maximum zoom level.
         */
        maxZoom(): number;
        /**
         * Set the maximum zoom level.
         *
         * @param zoom The new maximum zoom level to use.
         */
        maxZoom(zoom: number): void;

        /**
         * Set the viewport state (pan & zoom) in one call.
         *
         * @param zoom The zoom level to set.
         * @param pan The pan to set (a rendered position).
         */
        viewport(zoom: number, pan: Position): void;

        /**
         * Get whether box selection is enabled. If enabled, the user must hold left-click to initiate panning.
         */
        boxSelectionEnabled(): boolean;
        /**
         * Set whether box selection is enabled. If enabled, the user must hold left-click to initiate panning.
         *
         * @param bool A truthy value enables box selection; a falsey value disables it.
         */
        boxSelectionEnabled(bool: boolean): void;

        /**
         * Get the on-screen width of the viewport in pixels.
         */
        width(): number;

        /**
         * Get the on-screen height of the viewport in pixels.
         */
        height(): number;

        /**
         * Get the extent of the viewport, a bounding box in model coordinates that lets you know what model positions are visible in the viewport.
         */
        extent(): Extent;

        /**
         * Get whether nodes are automatically locked (i.e. if true, nodes are locked despite their individual state).
         */
        autolock(): boolean;
        /**
         * Set whether nodes are automatically locked (i.e. if true, nodes are locked despite their individual state).
         *
         * @param bool A truthy value enables autolocking; a falsey value disables it.
         */
        autolock(bool: boolean): void;

        /**
         * Get whether nodes are automatically ungrabified (i.e. if true, nodes are ungrabbale despite their individual state).
         */
        autoungrabify(): boolean;
        /**
         * Set whether nodes are automatically ungrabified (i.e. if true, nodes are ungrabbale despite their individual state).
         *
         * @param bool A truthy value enables autolocking; a falsey value disables it.
         */
        autoungrabify(bool: boolean): void;

        /**
         * Get whether nodes are automatically unselectified (i.e. if true, nodes are unselectable despite their individual state).
         */
        autounselectify(): boolean;
        /**
         * Set whether nodes are automatically unselectified (i.e. if true, nodes are unselectable despite their individual state).
         *
         * @param bool A truthy value enables autolocking; a falsey value disables it.
         */
        autounselectify(bool: boolean): void;

        /**
         * Force the renderer to redraw (i.e. draw a new frame).
         *
         * This function forces the renderer to draw a new frame. It is useful for very specific edgecases, such as in certain UI plugins, but it should not be needed for most developers.
         */
        forceRender(): void;

        /**
         * Force the renderer to recalculate the viewport bounds.
         *
         * If your code resizes the graph's dimensions or position (i.e. by changing the style of the HTML DOM element that holds the graph), you will want to call cy.resize() to have the graph resize and redraw itself.
         *
         * Cytoscape.js can not automatically monitor the bounding box of the viewport, as querying the DOM for those dimensions can be expensive. Although cy.resize() is automatically called for you on the window's resize event, there is no resize or style event for arbitrary DOM elements.
         */
        resize(): CollectionElements;
    }

    interface InstanceAnimation {
        // http://js.cytoscape.org/#core/animation

        /**
         * Get whether the viewport is currently being animated.
         */
        animated(): boolean;

        /**
         * Animate the viewport.
         *
         * @param anis An object containing the details of the animation.
         * zoom A zoom level to which the graph will be animated.
         * pan A panning position to which the graph will be animated.
         * panBy A relative panning position to which the graph will be animated.
         * fit An object containing fitting options from which the graph will be animated.
         * eles Elements or a selector to which the viewport will be fitted.
         * padding Padding to use with the fitting.
         * center An object containing centring options from which the graph will be animated.
         * eles Elements or a selector to which the viewport will be centred.
         * @param options An object containing animation options.
         * duration - The duration of the animation in milliseconds.
         * queue - A boolean indicating whether to queue the animation.
         * complete - A function to call when the animation is done.
         * step - A function to call each time the animation steps.
         */
        animate(anis: {
            zoom?: number,
            pan?: Position,
            panBy?: Position,
            fit?: {
                eles: Collection,
                padding?: number
            },
            center?: {
                eles: Collection
            }
        }, options?: {
            duration?: number,
            queue?: boolean,
            complete?: () => void,
            step?: () => void
        }): Cy.Instance;

        /**
         * Add a delay between animations for the viewport.
         *
         * @param duration How long the delay should be in milliseconds.
         * @param complete A function to call when the delay is complete.
         */
        delay(duration: number, complete?: () => void): Cy.Instance;

        /**
         * Stop all viewport animations that are currently running.
         *
         * @param clearQueue A boolean, indicating whether the queue of animations should be emptied.
         * @param jumpToEnd A boolean, indicating whether the currently-running animations should jump to their ends rather than just stopping midway.
         */
        stop(clearQueue?: boolean, jumpToEnd?: boolean): Cy.Instance;

        /**
         * Remove all queued animations for the viewport.
         */
        clearQueue(): Cy.Instance;
    }

    interface InstanceLayout {
        //TODO: http://js.cytoscape.org/#core/layout
        layout(layout: LayoutOptions): void;

    }

    interface InstanceStyle {
        //TODO: http://js.cytoscape.org/#core/style
    }

    interface InstanceExport {
        /**
         * Export the current graph view as a PNG image in Base64 representation.
         */
        png(): string;
        /**
         * Export the current graph view as a PNG image in Base64 representation.
         */
        png(options: ExportOptions): string;

        /**
         * Export the current graph view as a JPG image in Base64 representation.
         */
        jpg(): string;
        /**
         * Export the current graph view as a JPG image in Base64 representation.
         */
        jpg(options: ExportOptions): string;

        /**
         * Export the current graph view as a JPG image in Base64 representation.
         */
        jpeg(): string;
        /**
         * Export the current graph view as a JPG image in Base64 representation.
         */
        jpeg(options: ExportOptions): string;

        /**
         * Export the graph as JSON, the same format used at initialisation.
         */
        json(): string;
    }

    interface Position {
        x: number;
        y: number;
    }

    interface LayoutInstance {
        //TODO: http://js.cytoscape.org/#layouts/layout-manipulation

        /**
         * Start running the layout.
         */
        run(): void;
        /**
         * Start running the layout.
         */
        start(): void;

        /**
         * Stop running the (asynchronous/discrete) layout.
         */
        stop(): void;
    }

    interface LayoutOptions {
        // TODO: http://js.cytoscape.org/#layouts
        /**
         *
         * The default is 'grid'.
         */
        name?: string;
        padding?: number;
        avoidOverlap?: boolean;
    }

    interface CytoscapeOptions {
        // very commonly used options:
        /**
         * A HTML DOM element in which the graph should be rendered.
         * This is optional if Cytoscape.js is run headlessly or if you initialise using jQuery (in which case your jQuery object already has an associated DOM element).
         *
         * The default is undefined.
         */
        container?: HTMLElement | JQuery;
        /**
         * The [[Stylesheet]] used to style the graph. For convenience, this option can alternatively be specified as a promise that resolves to the stylesheet.
         */
        style?: Stylesheet[]|Promise<Stylesheet[]>;
        /**
         * An array of [[Elements]] specified as plain objects. For convenience, this option can alternatively be specified as a promise that resolves to the elements JSON.
         */
        elements?: ElementsDefinition|ElementDefinition[]|Promise<ElementsDefinition>|Promise<ElementDefinition[]>;
        /**
         * A plain object that specifies layout options. Which layout is initially run is specified by the name field. Refer to a layout's documentation for the options it supports. If you want to specify your node positions yourself in your elements JSON, you can use the preset layout — by default it does not set any positions, leaving your nodes in their current positions (e.g. specified in options.elements at initialisation time)
         */
        layout?: LayoutOptions;
        /**
         * A callback function that is called when Cytoscape.js has loaded the graph and the layout has specified initial positions of the nodes. After this point, rendering can happen, the user can interact with the graph, et cetera.
         */
        ready?: (evt: any) => void;

        // initial viewport state:
        /**
         * The initial zoom level of the graph. Make sure to disable viewport manipulation options, such as fit, in your layout so that it is not overridden when the layout is applied. You can set options.minZoom and options.maxZoom to set restrictions on the zoom level.
         *
         * The default value is 1.
         */
        zoom?: number;
        /**
         * The initial panning position of the graph. Make sure to disable viewport manipulation options, such as fit, in your layout so that it is not overridden when the layout is applied.
         */
        pan?: Position;

        // interaction options?:
        /**
         * A minimum bound on the zoom level of the graph. The viewport can not be scaled smaller than this zoom level.
         *
         * The default value is 1e-50.
         */
        minZoom?: number;
        /**
         * A maximum bound on the zoom level of the graph. The viewport can not be scaled larger than this zoom level.
         *
         * The default value is 1e50.
         */
        maxZoom?: number;
        /**
         * Whether zooming the graph is enabled, both by user events and programmatically.
         *
         * The default value is true.
         */
        zoomingEnabled?: boolean;
        /**
         * Whether user events (e.g. mouse wheel, pinch-to-zoom) are allowed to zoom the graph. Programmatic changes to zoom are unaffected by this option.
         *
         * The default value is true.
         */
        userZoomingEnabled?: boolean;
        /**
         * Whether panning the graph is enabled, both by user events and programmatically.
         *
         * The default value is true.
         */
        panningEnabled?: boolean;
        /**
         * Whether user events (e.g. dragging the graph background) are allowed to pan the graph. Programmatic changes to pan are unaffected by this option.
         *
         * The default value is true.
         */
        userPanningEnabled?: boolean;
        /**
         * Whether box selection (i.e. drag a box overlay around, and release it to select) is enabled. If enabled, the user must taphold to pan the graph.
         *
         * The default value is false.
         */
        boxSelectionEnabled?: boolean;
        /**
         * A string indicating the selection behaviour from user input. By default, this is set automatically for you based on the type of input device detected. On touch devices, 'additive' is default — a new selection made by the user adds to the set of currenly selected elements. On mouse-input devices, 'single' is default — a new selection made by the user becomes the entire set of currently selected elements (i.e. the previous elements are unselected).
         *
         * The default value is (isTouchDevice ? 'additive' : 'single').
         */
        selectionType?: SelectionType;
        /**
         * A nonnegative integer that indicates the maximum allowable distance that a user may move during a tap gesture, on touch devices and desktop devices respectively. This makes tapping easier for users. These values have sane defaults, so it is not advised to change these options unless you have very good reason for doing so. Larger values will almost certainly have undesirable consequences.
         *
         * The default value is is 8.
         */
        touchTapThreshold?: number;
        /**
         * A nonnegative integer that indicates the maximum allowable distance that a user may move during a tap gesture, on touch devices and desktop devices respectively. This makes tapping easier for users. These values have sane defaults, so it is not advised to change these options unless you have very good reason for doing so. Larger values will almost certainly have undesirable consequences.
         *
         * The default value is 4.
         */
        desktopTapThreshold?: number;
        /**
         * Whether nodes should be locked (not draggable at all) by default (if true, overrides individual node state).
         *
         * The default value is false.
         */
        autolock?: boolean;
        /**
         * Whether nodes should be ungrabified (not grabbable by user) by default (if true, overrides individual node state).
         *
         * The default value is false.
         */
        autoungrabify?: boolean;
        /**
         * Whether nodes should be unselectified (immutable selection state) by default (if true, overrides individual element state).
         *
         * The default value is false.
         */
        autounselectify?: boolean;

        // rendering options:
        /**
         * A convenience option that initialises the instance to run headlessly. You do not need to set this in environments that are implicitly headless (e.g. Node.js). However, it is handy to set headless: true if you want a headless instance in a browser.
         *
         * The default value is false.
         */
        headless?: boolean;
        /**
         * A boolean that indicates whether styling should be used. For headless (i.e. outside the browser) environments, display is not necessary and so neither is styling necessary — thereby speeding up your code. You can manually enable styling in headless environments if you require it for a special case. Note that it does not make sense to disable style if you plan on rendering the graph.
         *
         * The default value is true.
         */
        styleEnabled?: boolean;
        /**
         * When set to true, the renderer does not render edges while the viewport is being manipulated. This makes panning, zooming, dragging, et cetera more responsive for large graphs.
         *
         * The default value is false.
         */
        hideEdgesOnViewport?: boolean;
        /**
         * hen set to true, the renderer does not render labels while the viewport is being manipulated. This makes panning, zooming, dragging, et cetera more responsive for large graphs.
         *
         * The default value is false.
         */
        hideLabelsOnViewport?: boolean;
        /**
         * When set to true, the renderer uses a texture (if supported) during panning and zooming instead of drawing the elements, making large graphs more responsive.
         *
         * The default value is false.
         */
        textureOnViewport?: boolean;
        /**
         * When set to true, the renderer will use a motion blur effect to make the transition between frames seem smoother. This can significantly increase the perceived performance for a large graphs.
         *
         * The default value is false.
         */
        motionBlur?: boolean;
        /**
         * When motionBlur: true, this value controls the opacity of motion blur frames. Higher values make the motion blur effect more pronounced.
         *
         * The default value is 0.2.
         */
        motionBlurOpacity?: number;
        /**
         * Changes the scroll wheel sensitivity when zooming. This is a multiplicative modifier. So, a value between 0 and 1 reduces the sensitivity (zooms slower), and a value greater than 1 increases the sensitivity (zooms faster).
         *
         * The default value is 1.
         */
        wheelSensitivity?: number;
        /**
         * Overrides the screen pixel ratio with a manually set value (1.0 or 0.666 recommended, if set). This can be used to increase performance on high density displays by reducing the effective area that needs to be rendered. If you want to use the hardware's actual pixel ratio at the expense of performance, you can set pixelRatio: 'auto'.
         *
         * The default value is 1.
         */
        pixelRatio?: number;
        /**
         * A callback function that is called when Cytoscape.js has rendered its first frame. This is useful for grabbing screenshots etc after initialision, but in general you should use ready instead.
         */
        initrender?: (evt: any) => void;
        /**
         *  A plain object containing options for the renderer to be used. The options.renderer.name field specifies which renderer is used. You need not specify anything for the renderer option, unless you want to specify one of the rendering options.
         */
        renderer?: Renderer;
    }

    interface ExportOptions {
        /**
         * The background colour of the image (transparent by default).
         */
        bg?: string;
        /**
         * Whether to export the current viewport view (false, default) or the entire graph (true).
         */
        full?: boolean;
        /**
         * This value specifies a positive number that scales the size of the resultant image.
         */
        scale?: number;
        /**
         * Specifies the scale automatically in combination with maxHeight such that the resultant image is no wider than maxWidth.
         */
        maxWidth?: number;
        /**
         * Specifies the scale automatically in combination with maxWidth such that the resultant image is no taller than maxHeight.
         */
        maxHeight?: number;
    }

    interface BoundingBoxOptions {
        /**
         * A boolean indicating whether to include nodes in the bounding box.
         */
        includeNodes: boolean;
        /**
         * A boolean indicating whether to include edges in the bounding box.
         */
        includeEdges: boolean;
        /**
         * A boolean indicating whether to include labels in the bounding box.
         */
        includeLabels: boolean;
        /**
         * A boolean indicating whether to include shadows in the bounding box (default true).
         */

        includeShadows: boolean
    }

    interface ZoomOptions {
        /**
         * The zoom level to set.
         */
        level: number;
        /**
         * The position about which to zoom.
         */
        position?: Position;
        /**
         * The rendered position about which to zoom.
         */
        renderedPosition?: Position;
    }

    interface Static {
        (options?: CytoscapeOptions): Instance;
        (extensionName: string, foo: string, bar: any): Instance;
        version: string;

        Promise<T>(): Cy.Promise<T>;
    }

    enum PromiseState {
        STATE_PENDING = 0,
        STATE_FULFILLED = 1,
        STATE_REJECTED = 2

    }

    interface Promise<T> {
        id: string;
        state: PromiseState;
        fulfillValue: T;
        rejectReason: any;
        onFulfilled: any[];
        onRejected: any[];

        fulfill(value: T): Promise<T>;
        reject(error: any): Promise<any>;
        then<U>(onFulfilled?: (value: T) => U | Promise<U>, onRejected?: (error: any) => U | Promise<U>): Promise<U>;
        then<U>(onFulfilled?: (value: T) => U | Promise<U>, onRejected?: (error: any) => void): Promise<U>;
    }
}

declare module "cytoscape" {
    export = cytoscape;
}

declare var cytoscape: Cy.Static;