-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph_perf.txt
More file actions
58 lines (31 loc) · 1.78 KB
/
Graph_perf.txt
File metadata and controls
58 lines (31 loc) · 1.78 KB
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
(base) [kamano@n007 ~]$ math
Mathematica 12.0.0 Kernel for Linux x86 (64-bit)
Copyright 1988-2019 Wolfram Research, Inc.
In[1]:= Timing[r=Table[RandomInteger[{1,1000000000}]<->RandomInteger[{1,10000000
00}],{100000000}];]
Out[1]= {64.7552, Null}
In[2]:= c=Outer[TwoWayRule,{1,2,3,4,5},{1,2,3,4,5}]
Out[2]= {{1 <-> 1, 1 <-> 2, 1 <-> 3, 1 <-> 4, 1 <-> 5},
> {2 <-> 1, 2 <-> 2, 2 <-> 3, 2 <-> 4, 2 <-> 5},
> {3 <-> 1, 3 <-> 2, 3 <-> 3, 3 <-> 4, 3 <-> 5},
> {4 <-> 1, 4 <-> 2, 4 <-> 3, 4 <-> 4, 4 <-> 5},
> {5 <-> 1, 5 <-> 2, 5 <-> 3, 5 <-> 4, 5 <-> 5}}
In[3]:= v=Table[RandomInteger[{1,1000000000}],{10000000}];
In[4]:= Timing[gr=Graph[v,Flatten[{r,c}]]]
Out[4]= {245.118, Graph[<189417725>, <100000025>]}
In[5]:= Timing[(vl=VertexList[gr])//Length]
Out[5]= {0., 189417725}
In[6]:= Timing[(el=EdgeList[gr])//Length]
Out[6]= {38.7531, 100000025}
In[7]:= v[[1]]
Out[7]= 306201488
In[8]:= Timing[Cases[el,UndirectedEdge[x_,y_]/;(x==1||y==1)]]
Out[8]= {79.7539, {1 1, 1 2, 1 3, 1 4, 1 5, 2 1,
> 3 1, 4 1, 5 1}}
In[9]:= Timing[gc=ConnectedComponents[gr];]
Out[9]= {190.109, Null}
In[10]:= Timing[pg=PathGraph[Range[100000000]]]
Out[10]= {135.091, Graph[<100000000>, <99999999>]}
In[11]:= Timing[(cmps=ConnectedComponents[pg])//Length]
Out[11]= {0., 1}
In[12]:=