Repository navigation
Expand file tree
/
Copy pathgraphs-example.cpp
More file actions
1634 lines (1512 loc) · 87.6 KB
/
Copy pathgraphs-example.cpp
File metadata and controls
1634 lines (1512 loc) · 87.6 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
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
#include "graphs.h"
void SiteGraph::FindLatticeConstant()
{
//! [Site lattice constant copy]
std::vector< std::vector< std::pair<int,int> > > SiteLists;
SiteLists.push_back(this->Sites);
int Counter = 1;
//! [Site lattice constant copy]
//! [Site lattice constant dihedral transform]
for( int CurrentElement = 1; CurrentElement < 8; CurrentElement++ )
{
std::vector< std::pair<int,int> > TempSites = this->Sites;
Dihedral Transform(CurrentElement);
std::for_each(TempSites.begin(), TempSites.end(), Transform);
std::sort(TempSites.begin(), TempSites.end());
//! [Site lattice constant dihedral transform]
//! [Site lattice constant shift check]
bool GlobalShifted = false;
for ( unsigned int CurrentList = 0; CurrentList < SiteLists.size(); CurrentList++ )
{
bool Shifted = true;
const std::pair< int, int> shift = std::make_pair(SiteLists[ CurrentList ].front().first - TempSites.front().first, SiteLists[ CurrentList ].front().second - TempSites.front().second);
unsigned int CurrentSite = 1;
while( Shifted && CurrentSite < SiteLists[ CurrentList ].size())
{
int ShiftX = SiteLists[ CurrentList ][ CurrentSite ].first - TempSites[ CurrentSite ].first;
int ShiftY = SiteLists[ CurrentList ][ CurrentSite ].second - TempSites[ CurrentSite ].second;
Shifted = Shifted && (shift == std::make_pair(ShiftX, ShiftY);
CurrentSite++;
}
GlobalShifted = GlobalShifted || Shifted;
}
//! [Site lattice constant shift check]
//! [Site lattice constant new rep]
if (!GlobalShifted)
{
SiteLists.push_back(TempSites);
Counter++;
}
//! [Site lattice constant new rep]
}
this->LatticeConstant = Counter;
}
bool SiteGraph::operator==(const SiteGraph & Other)
{
if( ( Other.LatticeConstant == this->LatticeConstant) &&
( Other.Order == this->Order) )
{
for( int currentFactor = 0; currentFactor < 8; currentFactor++)
{
//! [Site isomorphism copy and transform]
std::vector< std::pair< int, int> > SitesCopy = Other.Sites;
Dihedral Transform(currentFactor);
std::for_each(SitesCopy.begin(), SitesCopy.end(), Transform);
std::sort(SitesCopy.begin(), SitesCopy.end());
//! [Site isomorphism copy and transform]
//! [Site isomorphism shift check]
bool Isomorphic = true;
const std::pair<int,int> shift = std::make_pair(this->Sites.front().first - SitesCopy.front().first, this->Sites.front().second - SitesCopy.front().second);
unsigned int CurrentSite = 0;
while(Isomorphic && CurrentSite < SitesCopy.size())
{
int ShiftX = (this->Sites[ CurrentSite ].first - SitesCopy[ CurrentSite ].first);
int ShiftY = (this->Sites[ CurrentSite ].second - SitesCopy[ CurrentSite ].second );
Isomorphic = (Isomorphic) && (shift == std::make_pair(ShiftX, ShiftY));
CurrentSite++;
}
if (this->AdjacencyList.size() > 0 && Other.AdjacencyList.size() > 0)
{
Isomorphic = Isomorphic || (this->AdjacencyList == Other.AdjacencyList);
}
if (Isomorphic)
{
return true;
}
//! [Site isomorphism shift check]
}
return false;
}
else
{
return false;
}
}
void SiteGraph::MakeCanonical()
{
//! [Creating site canonical storage]
std::vector< std::pair<int,int> > CanonicalSites;
//! [Creating site canonical storage]
//! [Transforming site canonical with Dihedral]
for( int currentFactor = 0; currentFactor < 8; currentFactor++)
{
std::vector< std::pair<int,int> > SitesCopy = this->Sites;
Dihedral Transform(currentFactor);
std::for_each(SitesCopy.begin(), SitesCopy.end(), Transform);
std::sort(SitesCopy.begin(), SitesCopy.end());
//! [Transforming site canonical with Dihedral]
//! [Shifting site canonical]
std::pair<int,int> shift = std::make_pair(-SitesCopy.front().first, -SitesCopy.front().second);
for(unsigned int CurrentSite = 0; CurrentSite < SitesCopy.size(); CurrentSite++)
{
SitesCopy[ CurrentSite ] = std::make_pair(SitesCopy[ CurrentSite ].first + shift.first, SitesCopy[ CurrentSite ].second + shift.second);
}
if( lexicographical_compare(CanonicalSites.begin(), CanonicalSites.end(), SitesCopy.begin(), SitesCopy.end() ) )
{
CanonicalSites = SitesCopy;
}
//! [Shifting site canonical]
}
this->Sites = CanonicalSites;
}
bool BondGraph::operator==( const BondGraph & Other)
{
if( (Other.Order == this->Order) )
{
for( int currentFactor = 0; currentFactor < 8; currentFactor++)
{
//! [Bond isomorphism copy and transform]
std::vector< std::pair< std::pair< int, int>, std::pair< int, int> > > BondsCopy = Other.Bonds;
Dihedral Transform(currentFactor);
std::for_each(BondsCopy.begin(), BondsCopy.end(), Transform);
for(unsigned int CurrentBond = 0; CurrentBond < BondsCopy.size(); CurrentBond++)
{
std::pair<int,int> Temp = BondsCopy.at(CurrentBond).first;
if( BondsCopy[ CurrentBond ].first > BondsCopy[ CurrentBond ].second)
{
BondsCopy[ CurrentBond ].first = BondsCopy[ CurrentBond ].second;
BondsCopy[ CurrentBond ].second = Temp;
}
}
std::sort(BondsCopy.begin(), BondsCopy.end());
//! [Bond isomorphism copy and transform]
//! [Bond isomorphism shift check]
std::pair<int, int> shift1 = std::make_pair(this->Bonds.front().first.first - BondsCopy.front().first.first, this->Bonds.front().first.second - BondsCopy.front().first.second);
std::pair<int, int> shift2 = std::make_pair(this->Bonds.front().second.first - BondsCopy.front().second.first, this->Bonds.front().second.second - BondsCopy.front().second.second);
bool Isomorphic = shift1 == shift2;
unsigned int CurrentBond = 0;
while( Isomorphic && CurrentBond < BondsCopy.size())
{
int ShiftX = this->Bonds[ CurrentBond ].first.first - BondsCopy[ CurrentBond ].first.first;
int ShiftY = this->Bonds[ CurrentBond ].first.second - BondsCopy[ CurrentBond ].first.second;
Isomorphic = Isomorphic && (shift1 == std::make_pair(ShiftX, ShiftY));
ShiftX = this->Bonds[ CurrentBond ].second.first - BondsCopy[ CurrentBond ].second.first;
ShiftY = this->Bonds[ CurrentBond ].second.second - BondsCopy[ CurrentBond ].second.second;
Isomorphic = Isomorphic && (shift2 == std::make_pair(ShiftX, ShiftY));
CurrentBond++;
}
if (Isomorphic)
{
return true;
}
//! [Bond isomorphism shift check]
}
return false;
}
else
{
return false;
}
}
void BondGraph::MakeCanonical()
{
int GlobalGraphKey = 0;
//! [Bond canonical storage]
std::vector<std::pair< std::pair<int,int>, std::pair<int,int> > > CanonicalBonds;
//! [Bond canonical storage]
//! [Bond canonical transform]
for( int currentFactor = 0; currentFactor < 8; currentFactor++)
{
int LocalGraphKey = 0;
std::vector< std::pair< std::pair< int, int>, std::pair<int,int> > > BondsCopy = this->Bonds;
Dihedral Transform(currentFactor);
std::for_each(BondsCopy.begin(), BondsCopy.end(), Transform);
for(unsigned int CurrentBond = 0; CurrentBond < BondsCopy.size(); CurrentBond++)
{
std::pair<int,int> Temp = BondsCopy[ CurrentBond ].first;
if( BondsCopy[ CurrentBond ].first > BondsCopy[ CurrentBond ].second)
{
BondsCopy[ CurrentBond ].first = BondsCopy[ CurrentBond ].second;
BondsCopy[ CurrentBond ].second = Temp;
}
}
std::sort(BondsCopy.begin(), BondsCopy.end());
//! [Bond canonical transform]
//! [Bond canonical shift]
std::pair<int,int> shift = std::make_pair(-BondsCopy.front().first.first, -BondsCopy.front().first.second);
for(unsigned int CurrentBond = 0; CurrentBond < BondsCopy.size(); CurrentBond++)
{
BondsCopy[ CurrentBond ].first = std::make_pair( BondsCopy[ CurrentBond ].first.first + shift.first, BondsCopy[ CurrentBond ].first.second + shift.second);
BondsCopy[ CurrentBond ].second = std::make_pair( BondsCopy[ CurrentBond ].second.first + shift.first, BondsCopy[ CurrentBond ].second.second + shift.second);
LocalGraphKey += BondsCopy[ CurrentBond ].first.first*this->Order + BondsCopy[ CurrentBond ].first.second;
LocalGraphKey += BondsCopy[ CurrentBond ].second.first*this->Order + BondsCopy[ CurrentBond ].second.second;
}
if( LocalGraphKey > GlobalGraphKey )
{
GlobalGraphKey = LocalGraphKey;
CanonicalBonds = BondsCopy;
}
//! [Bond canonical shift]
}
this->Bonds = CanonicalBonds;
}
void BondGraph::GenerateAdjacencyList()
{
//! [Bond adjacency copy]
std::vector< std::pair<int, int> > SiteList;
for(unsigned int CurrentBond = 0; CurrentBond < this->Bonds.size(); CurrentBond++)
{
SiteList.push_back( this->Bonds[ CurrentBond ].first );
SiteList.push_back( this->Bonds[ CurrentBond ].second );
}
std::sort(SiteList.begin(), SiteList.end());
std::vector< std::pair<int,int> >::iterator TrueEnd;
TrueEnd = unique(SiteList.begin(), SiteList.end() );
SiteList.resize( TrueEnd - SiteList.begin() );
this->AdjacencyList.resize(this->Bonds.size());
//! [Bond adjacency copy]
//! [Bond adjacency fill list]
for( unsigned int CurrentBond = 0; CurrentBond < this->Bonds.size(); CurrentBond++)
{
std::vector< std::pair<int, int> >::iterator FirstSite;
std::vector< std::pair<int, int> >::iterator SecondSite;
FirstSite = std::find(SiteList.begin(), SiteList.end(), this->Bonds[ CurrentBond ].first);
SecondSite = std::find(SiteList.begin(), SiteList.end(), this->Bonds[ CurrentBond ].second);
this->AdjacencyList[CurrentBond] = std::make_pair( FirstSite - SiteList.begin(), SecondSite - SiteList.begin() ) ;
}
//! [Bond adjacency fill list]
std::sort( this->AdjacencyList.begin(), this->AdjacencyList.end());
}
void BondGraph::FindLatticeConstant()
{
//! [Bond lattice constant copy]
std::vector< std::vector< std::pair< std::pair<int, int >, std::pair<int,int> > > > BondLists;
BondLists.push_back(this->Bonds);
int Counter = 1;
//! [Bond lattice constant copy]
//! [Bond lattice constant transform]
for( int CurrentElement = 1; CurrentElement < 8; CurrentElement++ )
{
std::vector< std::pair< std::pair<int, int>, std::pair<int,int> > > TempBonds = this->Bonds;
Dihedral Transform(CurrentElement);
std::for_each(TempBonds.begin(), TempBonds.end(), Transform);
for(unsigned int CurrentBond = 0; CurrentBond < TempBonds.size(); CurrentBond++)
{
std::pair<int,int> Temp = TempBonds[ CurrentBond ].first;
if( TempBonds[ CurrentBond ].first > TempBonds[ CurrentBond ].second)
{
TempBonds[ CurrentBond ].first = TempBonds[ CurrentBond ].second;
TempBonds[ CurrentBond ].second = Temp;
}
}
std::sort(TempBonds.begin(), TempBonds.end());
//! [Bond lattice constant transform]
//! [Bond lattice constant shift check]
bool GlobalShifted = false;
for ( unsigned int CurrentList = 0; CurrentList < BondLists.size(); CurrentList++ )
{
const std::pair< int, int> shift1 = std::make_pair(BondLists[ CurrentList ].front().first.first - TempBonds.front().first.first, BondLists[ CurrentList ].front().first.second - TempBonds.front().first.second);
const std::pair< int, int> shift2 = std::make_pair(BondLists[ CurrentList ].front().second.first - TempBonds.front().second.first, BondLists[ CurrentList ].front().second.second - TempBonds.front().second.second);
bool Shifted = (shift1 == shift2);
unsigned int CurrentBond = 1;
while( Shifted && CurrentBond < BondLists[ CurrentList ].size())
{
int ShiftX = BondLists[ CurrentList ][ CurrentBond ].first.first - TempBonds[ CurrentBond ].first.first;
int ShiftY = BondLists[ CurrentList ][ CurrentBond ].first.second - TempBonds[ CurrentBond ].first.second;
Shifted = Shifted && (shift1 == std::make_pair(ShiftX, ShiftY);
ShiftX = BondLists[ CurrentList ][ CurrentBond ].second.first - TempBonds[ CurrentBond ].second.first;
ShiftY = BondLists[ CurrentList ][ CurrentBond ].second.second - TempBonds[ CurrentBond ].second.second;
Shifted = Shifted && (shift2 == std::make_pair(ShiftX, ShiftY));
CurrentBond++;
}
GlobalShifted = GlobalShifted || Shifted;
}
//! [Bond lattice constant shift check]
//! [Bond lattice constant store]
if (!GlobalShifted)
{
BondLists.push_back(TempBonds);
Counter++;
}
//! [Bond lattice constant store]
}
this->LatticeConstant = Counter;
}
void ConstructSiteBasedGraphs(std::vector< std::vector< SiteGraph > > & graphs, int FinalOrder)
{
//! [Site grab back info]
std::vector< SiteGraph > NewGraphs;
int GlobalIdentifier = graphs.back().back().Identifier;
int CurrentOrder = graphs.back().back().Order + 1;
//! [Site grab back info]
while (CurrentOrder <= FinalOrder)
{
cout<<"Current Order: "<<CurrentOrder<<" Current Global ID: "<<GlobalIdentifier<<endl;
NewGraphs.clear();
for( unsigned int CurrentGraph = 0; CurrentGraph < graphs.back().size(); CurrentGraph++)
{
int tid;
//! [Site get graph ready]
std::pair<int,int> NewSite;
SiteGraph OldGraph = graphs.back().at(CurrentGraph);
SiteGraph NewGraph;
//! [Site get graph ready]
omp_set_num_threads( CurrentOrder - 1 );
#pragma omp parallel private(tid, NewSite, NewGraph) shared(OldGraph, NewGraphs, GlobalIdentifier)
{
tid = omp_get_thread_num();
//! [Site make new graph]
for( int i = 0; i < 4; i++ )
{
switch ( i )
{
case 0 :
NewSite = std::make_pair( OldGraph.Sites[ tid ].first + 1, OldGraph.Sites[ tid ].second);
break;
case 1 :
NewSite = std::make_pair( OldGraph.Sites[ tid ].first, OldGraph.Sites[ tid ].second + 1);
break;
case 2 :
NewSite = std::make_pair( OldGraph.Sites[ tid ].first - 1, OldGraph.Sites[ tid ].second);
break;
case 3 :
NewSite = std::make_pair( OldGraph.Sites[ tid ].first , OldGraph.Sites[ tid ].second - 1);
break;
}
if( !std::binary_search( OldGraph.Sites.begin(), OldGraph.Sites.end(), NewSite))
{
NewGraph = OldGraph;
NewGraph.AddSite( NewSite.first, NewSite.second);
NewGraph.Order = OldGraph.Order + 1;
NewGraph.MakeCanonical();
NewGraph.GenerateAdjacencyList();
//! [Site make new graph]
bool Exists = false;
#pragma omp critical
{
//! [Site check new graph]
for( unsigned int CurrentIndex = 0; CurrentIndex < NewGraphs.size(); CurrentIndex++ )
{
Exists = Exists || (NewGraph.Sites == NewGraphs[ CurrentIndex ].Sites );
//Exists = Exists || (NewGraph.AdjacencyList == NewGraphs.at(CurrentIndex).AdjacencyList);
}
if( !Exists )
{
NewGraph.Identifier = ++GlobalIdentifier;
NewGraph.FindLatticeConstant();
NewGraph.LowField = false;
NewGraphs.push_back( NewGraph );
}
//! [Site check new graph]
}
}
}
}
}
graphs.insert(graphs.end(), NewGraphs);
CurrentOrder++;
}
}
void ConstructRectangularSiteGraphs(std::vector< std::vector< SiteGraph > > & graphs, unsigned int FinalWidth, unsigned int FinalHeight)
{
graphs.resize(FinalWidth);
int GlobalIdentifier = 0;
//! [First rectangles loops]
for( unsigned int CurrentGraphWidth = 1; CurrentGraphWidth <= FinalWidth; CurrentGraphWidth++)
{
for( unsigned int CurrentGraphHeight = 1; CurrentGraphHeight <= FinalHeight; CurrentGraphHeight++)
{
//! [First rectangles loops]
//! [First rectangles temp storage]
unsigned int CurrentOrder = CurrentGraphHeight * CurrentGraphWidth;
std::vector< std::pair<int, int> > SiteList;
SiteList.resize(CurrentOrder);
std::vector< std::pair<int, int> > Subgraphs;
//! [First rectangles temp storage]
//! [First rectangles filling vectors]
for( unsigned int CurrentCheckWidth = 1; CurrentCheckWidth <= CurrentGraphWidth; CurrentCheckWidth++)
{
for (unsigned int CurrentCheckHeight = 1; CurrentCheckHeight <= CurrentGraphHeight; CurrentCheckHeight++)
{
SiteList.at(CurrentCheckHeight - 1 + (CurrentCheckWidth- 1)*CurrentGraphHeight) = std::make_pair(CurrentCheckWidth - 1, CurrentCheckHeight - 1);
int SubgraphCount = (CurrentGraphWidth + 1 - CurrentCheckWidth)*(CurrentGraphHeight + 1 - CurrentCheckHeight);
//! [First rectangles filling vectors]
//! [First rectangles check subgraph]
bool ThisGraph = (CurrentGraphHeight == CurrentCheckHeight) && (CurrentGraphWidth == CurrentCheckWidth);
if( SubgraphCount > 0 &&
!ThisGraph
)
{
Subgraphs.push_back(std::make_pair( SubgraphCount, graphs.at(CurrentCheckWidth - 1).at(CurrentCheckHeight - 1).Identifier ) );
}
//! [First rectangles check subgraph]
}
}
//! [First rectangles insert graph]
SiteGraph NewGraph(SiteList, GlobalIdentifier++, CurrentOrder, 1, Subgraphs);
NewGraph.GenerateAdjacencyList();
NewGraph.LowField = false;
graphs.at(CurrentGraphWidth - 1).push_back(NewGraph);
//! [First rectangles insert graph]
}
}
}
void ConstructRectangularSiteGraphs(std::vector< std::vector< SiteGraph > > & graphs, unsigned int FinalOrder)
{
graphs.resize(FinalOrder);
int GlobalIdentifier = 0;
//! [Second rectangles loops]
for( unsigned int CurrentGraphWidth = 1; CurrentGraphWidth <= FinalOrder; CurrentGraphWidth++)
{
for( unsigned int CurrentGraphHeight = 1; CurrentGraphHeight <= FinalOrder && CurrentGraphHeight*CurrentGraphWidth <= FinalOrder; CurrentGraphHeight++)
{
unsigned int CurrentOrder = CurrentGraphHeight * CurrentGraphWidth;
//! [Second rectangles loops]
//! [Second rectangles temp storage]
std::vector< std::pair<int, int> > SiteList;
SiteList.resize(CurrentOrder);
std::vector< std::pair<int, int> > Subgraphs;
//! [Second rectangles temp storage]
//! [Second rectangles filling vectors]
for( unsigned int CurrentCheckWidth = 1; CurrentCheckWidth <= CurrentGraphWidth; CurrentCheckWidth++)
{
for (unsigned int CurrentCheckHeight = 1; CurrentCheckHeight <= CurrentGraphHeight; CurrentCheckHeight++)
{
SiteList.at(CurrentCheckHeight - 1 + (CurrentCheckWidth- 1)*CurrentGraphHeight) = make_pair(CurrentCheckWidth - 1, CurrentCheckHeight - 1);
int SubgraphCount = (CurrentGraphWidth + 1 - CurrentCheckWidth)*(CurrentGraphHeight + 1 - CurrentCheckHeight);
//! [Second rectangles filling vectors]
//! [Second rectangles check subgraph]
bool ThisGraph = (CurrentGraphHeight == CurrentCheckHeight) && (CurrentGraphWidth == CurrentCheckWidth);
if( SubgraphCount > 0 &&
!ThisGraph
)
{
Subgraphs.push_back(make_pair( SubgraphCount, graphs.at(CurrentCheckWidth - 1).at(CurrentCheckHeight - 1).Identifier ) );
}
//! [Second rectangles check subgraph]
}
}
//! [Second rectangles insert graph]
SiteGraph NewGraph(SiteList, GlobalIdentifier++, CurrentOrder, 1, Subgraphs);
NewGraph.GenerateAdjacencyList();
NewGraph.LowField = false;
graphs.at(CurrentGraphWidth - 1).push_back(NewGraph);
//! [Second rectangles insert graph]
}
}
}
void ConstructBondBasedGraphs(std::vector< std::vector< BondGraph > > & graphs, int FinalOrder)
{
//! [Bond grab back info]
std::vector< BondGraph > NewGraphs;
int GlobalIdentifier = graphs.back().back().Identifier;
int CurrentOrder = graphs.back().back().Order + 1;
//! [Bond grab back info]
while (CurrentOrder <= FinalOrder)
{
cout<<CurrentOrder<<endl;
NewGraphs.clear();
for( unsigned int CurrentGraph = 0; CurrentGraph < graphs.back().size(); CurrentGraph++)
{
//! [Bond get graph ready]
BondGraph OldGraph = graphs.back().at(CurrentGraph);
std::pair< std::pair< int, int>, std::pair< int, int> > NewBond;
std::pair< int, int> NewSite;
BondGraph NewGraph;
//! [Bond get graph ready]
int tid;
#pragma omp parallel private(tid, NewSite, NewBond, NewGraph) shared(OldGraph, NewGraphs, GlobalIdentifier) num_threads(OldGraph.Bonds.size())
{
tid = omp_get_thread_num();
//! [Bond make new graph]
for( int i = 0; i < 6; i++)
{
switch( i )
{
case 0 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first, OldGraph.Bonds[ tid ].first.second + 1);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].first, NewSite);
} //Add a bond on the left, pointing up
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first, OldGraph.Bonds[ tid ].second.second + 1);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].second, NewSite);
} // Add a bond on the top, pointing up
break;
case 1 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first, OldGraph.Bonds[ tid ].second.second + 1);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].second, NewSite);
} //Add a bond on the right, pointing up
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first + 1, OldGraph.Bonds[ tid ].second.second);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].second, NewSite);
} // Add a bond on top, pointing right
break;
case 2 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first + 1, OldGraph.Bonds[ tid ].second.second);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].second, NewSite);
} // Add a bond on the right, pointing right
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first + 1, OldGraph.Bonds[ tid ].first.second);
NewBond = std::make_pair(OldGraph.Bonds[ tid ].first, NewSite);
} // Add a bond on the bottom, pointing right
break;
case 3 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first - 1, OldGraph.Bonds[ tid ].first.second);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].first);
} // Add a bond on the left, pointing left
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first - 1, OldGraph.Bonds[ tid ].second.second);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].second);
} // Add a bond on the top, pointing left
break;
case 4 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first, OldGraph.Bonds[ tid ].first.second - 1);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].first);
} // Add a bond to the left, pointing down
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first - 1, OldGraph.Bonds[ tid ].first.second);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].first);
} // Add a bond to the bottom, pointing left
break;
case 5 :
if( OldGraph.Bonds[ tid ].first.first != OldGraph.Bonds[ tid ].second.first ) //Bond is horizontal
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].second.first, OldGraph.Bonds[ tid ].second.second - 1);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].second);
} // Add a bond to the right, pointing down
else
{
NewSite = std::make_pair(OldGraph.Bonds[ tid ].first.first, OldGraph.Bonds[ tid ].first.second - 1);
NewBond = std::make_pair(NewSite, OldGraph.Bonds[ tid ].first);
} // Add a bond to the bottom, pointing down
break;
}
if( !std::binary_search( OldGraph.Bonds.begin(), OldGraph.Bonds.end(), NewBond))
{
NewGraph = OldGraph;
NewGraph.AddBond( NewBond.first, NewBond.second);
NewGraph.Order = OldGraph.Order + 1;
NewGraph.MakeCanonical();
//! [Bond make new graph]
//! [Bond check new graph]
bool Exists = false;
#pragma omp critical
{
for( unsigned int CurrentIndex = 0; CurrentIndex < NewGraphs.size(); CurrentIndex++ )
{
Exists = Exists || (NewGraph == NewGraphs[ CurrentIndex ] );
}
if( !Exists )
{
NewGraph.Identifier = ++GlobalIdentifier;
NewGraph.FindLatticeConstant();
NewGraph.GenerateAdjacencyList();
NewGraph.LowField = true;
NewGraphs.push_back( NewGraph );
}
}
//! [Bond check new graph]
}
}
}
}
graphs.insert(graphs.end(), NewGraphs);
CurrentOrder++;
}
}
void FindSubgraphs(std::vector< SiteGraph > & GraphList)
{
int tid;
int gid;
int MaxSize = omp_get_num_procs();
//! [Single vector site find subgraphs search]
for( unsigned int CurrentGraphGroup = 0; CurrentGraphGroup*MaxSize <= GraphList.size(); CurrentGraphGroup++)
{
#pragma omp parallel private(tid, gid) shared(MaxSize, CurrentGraphGroup) num_threads( MaxSize )
{
tid = omp_get_thread_num();
gid = tid + CurrentGraphGroup * MaxSize;
//! [Single vector site find subgraphs search]
if ( (unsigned int) gid < GraphList.size() )
{
//! [Single vector site find subgraphs single]
GraphList[ gid ].SubgraphList.push_back(std::make_pair(GraphList[ gid ].Order, 0));
//! [Single vector site find subgraphs single]
unsigned int CurrentCheck = 1;
//! [Single vector site find subgraphs reps]
while (CurrentCheck < (unsigned int) gid && GraphList.at(CurrentCheck).Order < GraphList[ gid ].Order)
{
std::vector< std::vector< std::pair< int, int> > > DistinctReps;
DistinctReps.resize(GraphList.at(CurrentCheck).LatticeConstant);
DistinctReps.push_back( GraphList.at(CurrentCheck).Sites );
for( int CurrentElement = 1; CurrentElement < 8; CurrentElement++)
{
Dihedral Transform(CurrentElement);
std::vector< std::pair< int, int> > ThisRep = GraphList.at(CurrentCheck).Sites;
std::for_each(ThisRep.begin(), ThisRep.end(), Transform);
std::sort(ThisRep.begin(), ThisRep.end());
bool GlobalShifted = false;
for ( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++ )
{
bool Shifted = true;
const std::pair< int, int> shift = std::make_pair(DistinctReps[ CurrentRep ].front().first - ThisRep.front().first, DistinctReps[ CurrentRep ].front().second - ThisRep.front().second);
unsigned int CurrentSite = 1;
while( Shifted && CurrentSite < DistinctReps[ CurrentRep ].size())
{
Shifted = Shifted && ((shift.first == (DistinctReps[ CurrentRep ][ CurrentSite ].first - ThisRep[ CurrentSite ].first)) && (shift.second == (DistinctReps[ CurrentRep ][ CurrentSite ].second - ThisRep[ CurrentSite ].second)));
CurrentSite++;
}
GlobalShifted = GlobalShifted || Shifted;
}
if (!GlobalShifted)
{
const std::pair< int, int> shift = std::make_pair(-ThisRep.front().first, -ThisRep.front().second);
for( unsigned int CurrentSite = 0; CurrentSite < ThisRep.size(); CurrentSite++)
{
ThisRep[ CurrentSite ].first += shift.first;
ThisRep[ CurrentSite ].second += shift.second;
}
DistinctReps.push_back(ThisRep);
}
}
//Now we have all distinct permutations of the graph!
//! [Single vector site find subgraphs reps]
//! [Single vector site find subgraphs shift count]
int Embeddings = 0;
for( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++)
{
std::pair< int, int> shift = std::make_pair(0,0);
int xMax = 0;
int yMax = 0;
int xMin = 0;
int yMin = 0;
for( unsigned int CurrentElement = 0; CurrentElement < GraphList[ gid ].Sites.size(); CurrentElement++)
{
xMax = (GraphList[ gid ].Sites[ CurrentElement ].first > xMax) ? GraphList[ gid ].Sites[ CurrentElement ].first : xMax;
yMax = (GraphList[ gid ].Sites[ CurrentElement ].second > yMax) ? GraphList[ gid ].Sites[ CurrentElement ].second : yMax;
xMin = (GraphList[ gid ].Sites[ CurrentElement ].first < xMin) ? GraphList[ gid ].Sites[ CurrentElement ].first : xMin;
yMin = (GraphList[ gid ].Sites[ CurrentElement ].second < yMin) ? GraphList[ gid ].Sites[ CurrentElement ].second : yMin;
}
for( int xBoost = xMin; xBoost <= xMax; xBoost++)
{
for( int yBoost = yMin; yBoost <= yMax; yBoost++)
{
shift = std::make_pair(xBoost, yBoost);
std::vector< std::pair< int, int> > CheckList = DistinctReps[ CurrentRep ];
unsigned int Counter = 0;
for( unsigned int CurrentSite = 0; CurrentSite < DistinctReps[ CurrentRep ].size(); CurrentSite++)
{
CheckList[ CurrentSite ].first += shift.first;
CheckList[ CurrentSite ].second += shift.second;
Counter += std::binary_search(GraphList[ gid ].Sites.begin(), GraphList[ gid ].Sites.end(), CheckList[ CurrentSite ]);
}
if ( Counter == CheckList.size() )
{
Embeddings++;
}
}
if (Embeddings > 0)
{
GraphList[ gid ].SubgraphList.push_back(make_pair(Embeddings, GraphList.at(CurrentCheck).Identifier));
}
}
}
//! [Single vector site find subgraphs shift count]
CurrentCheck++;
}
}
}
}
}
void FindSubgraphs(std::vector< std::vector< SiteGraph > > & GraphList)
{
//! [Double vector site find subgraphs search]
for( unsigned int CurrentGraphHeight = 1; CurrentGraphHeight < GraphList.size(); CurrentGraphHeight++)
{
int tid;
int gid;
int MaxSize = omp_get_num_procs();
for( unsigned int CurrentGraphGroup = 0; CurrentGraphGroup*MaxSize <= GraphList[ CurrentGraphHeight ].size(); CurrentGraphGroup++)
{
omp_set_num_threads( MaxSize );
#pragma omp parallel private(tid, gid) shared(MaxSize, CurrentGraphGroup, CurrentGraphHeight)
{
tid = omp_get_thread_num();
gid = tid + (CurrentGraphGroup * MaxSize);
if( (unsigned int) gid < GraphList[ CurrentGraphHeight ].size() )
{
//! [Double vector site find subgraphs search]
//! [Double vector site find subgraphs single]
GraphList[ CurrentGraphHeight ][ gid ].SubgraphList.push_back( std::make_pair(GraphList[ CurrentGraphHeight ][ gid ].Order, 0) );
//! [Double vector site find subgraphs single]
for( unsigned int CurrentCheckHeight = 1; CurrentCheckHeight < CurrentGraphHeight; CurrentCheckHeight++ )
{
for(unsigned int CurrentCheckWidth = 0; CurrentCheckWidth < GraphList[ CurrentCheckHeight ].size(); CurrentCheckWidth++ )
{
//! [Double vector site find subgraphs reps]
std::vector< std::vector< std::pair< int, int> > > DistinctReps;
DistinctReps.push_back( GraphList[ CurrentCheckHeight ].at( CurrentCheckWidth ).Sites );
for( int CurrentElement = 1; CurrentElement < 8; CurrentElement++)
{
Dihedral Transform(CurrentElement);
std::vector< std::pair< int, int> > ThisRep = GraphList[ CurrentCheckHeight ][ CurrentCheckWidth ].Sites;
std::for_each( ThisRep.begin(), ThisRep.end(), Transform );
std::sort( ThisRep.begin(), ThisRep.end() );
bool GlobalShifted = false;
for ( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++ )
{
bool Shifted = true;
const std::pair< int, int> shift = make_pair(DistinctReps[ CurrentRep ].front().first - ThisRep.front().first, DistinctReps[ CurrentRep ].front().second - ThisRep.front().second);
unsigned int CurrentSite = 1;
while( Shifted && CurrentSite < DistinctReps[ CurrentRep ].size())
{
Shifted = Shifted && ((shift.first == (DistinctReps[ CurrentRep ][ CurrentSite ].first - ThisRep[ CurrentSite ].first)) && (shift.second == (DistinctReps[ CurrentRep ][ CurrentSite ].second - ThisRep[ CurrentSite ].second)));
CurrentSite++;
}
GlobalShifted = GlobalShifted || Shifted;
}
if ( !GlobalShifted )
{
const std::pair< int, int> shift = std::make_pair(-ThisRep.front().first, -ThisRep.front().second);
for( unsigned int CurrentSite = 0; CurrentSite < ThisRep.size(); CurrentSite++)
{
ThisRep[ CurrentSite ].first += shift.first;
ThisRep[ CurrentSite ].second += shift.second;
}
DistinctReps.push_back(ThisRep);
}
}
//! [Double vector site find subgraphs reps]
//Now we have all distinct permutations of the graph!
//! [Double vector site find subgraphs shift count]
int Embeddings = 0;
for( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++)
{
std::pair< int, int> shift = std::make_pair(0,0);
int xMax = 0;
int xMin = 0;
int yMax = 0;
int yMin = 0;
for( unsigned int CurrentElement = 0; CurrentElement < GraphList[ CurrentGraphHeight ][ gid ].Sites.size(); CurrentElement++)
{
xMax = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first > xMax) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first : xMax;
yMax = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second > yMax) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second : yMax;
xMin = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first < xMin) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first : xMin;
yMin = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second < yMin) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second : yMin;
}
for( int xBoost = xMin; xBoost <= xMax; xBoost++)
{
for( int yBoost = yMin; yBoost <= yMax; yBoost++)
{
shift = std::make_pair(xBoost, yBoost);
std::vector< std::pair< int, int> > CheckList = DistinctReps[ CurrentRep ];
unsigned int Counter = 0;
for( unsigned int CurrentSite = 0; CurrentSite < DistinctReps[ CurrentRep ].size(); CurrentSite++)
{
CheckList[ CurrentSite ].first += shift.first;
CheckList[ CurrentSite ].second += shift.second;
Counter += std::binary_search(GraphList[ CurrentGraphHeight ][ gid ].Sites.begin(), GraphList[ CurrentGraphHeight ][ gid ].Sites.end(), CheckList[ CurrentSite ]);
}
if ( Counter == CheckList.size() )
{
Embeddings++;
}
}
}
}
if (Embeddings > 0)
{
GraphList[ CurrentGraphHeight ][ gid ].SubgraphList.push_back( std::make_pair(Embeddings, GraphList[ CurrentCheckHeight ][ CurrentCheckWidth ].Identifier));
}
//! [Double vector site find subgraphs shift count]
}
}
}
}
}
}
}
void FindSubgraphs(std::vector< std::vector< SiteGraph > > & GraphList, unsigned int Index)
{
//! [Double vector site index find subgraphs search]
unsigned int CurrentGraphHeight = Index - 1;
if ( CurrentGraphHeight < GraphList.size() )
{
int tid;
int gid;
int MaxSize = omp_get_num_procs();
for( unsigned int CurrentGraphGroup = 0; CurrentGraphGroup*MaxSize <= GraphList[ CurrentGraphHeight ].size(); CurrentGraphGroup++)
{
omp_set_num_threads( MaxSize );
#pragma omp parallel private(tid, gid) shared(MaxSize, CurrentGraphGroup, CurrentGraphHeight)
{
tid = omp_get_thread_num();
gid = tid + (CurrentGraphGroup * MaxSize);
//! [Double vector site index find subgraphs search]
if( (unsigned int) gid < GraphList[ CurrentGraphHeight ].size() )
{
//! [Double vector site index find subgraphs single]
GraphList[ CurrentGraphHeight ][ gid ].SubgraphList.push_back( std::make_pair(GraphList[ CurrentGraphHeight ][ gid ].Order, 0) );
//! [Double vector site index find subgraphs single]
for( unsigned int CurrentCheckHeight = 1; CurrentCheckHeight < CurrentGraphHeight; CurrentCheckHeight++ )
{
for(unsigned int CurrentCheckWidth = 0; CurrentCheckWidth < GraphList[ CurrentCheckHeight ].size(); CurrentCheckWidth++ )
{
//! [Double vector site index find subgraphs reps]
std::vector< std::vector< std::pair< int, int> > > DistinctReps;
DistinctReps.push_back( GraphList[ CurrentCheckHeight ].at( CurrentCheckWidth ).Sites );
for( int CurrentElement = 1; CurrentElement < 8; CurrentElement++)
{
Dihedral Transform(CurrentElement);
std::vector< std::pair< int, int> > ThisRep = GraphList[ CurrentCheckHeight ][ CurrentCheckWidth ].Sites;
std::for_each( ThisRep.begin(), ThisRep.end(), Transform );
std::sort( ThisRep.begin(), ThisRep.end() );
bool GlobalShifted = false;
for ( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++ )
{
bool Shifted = true;
const std::pair< int, int> shift = make_pair(DistinctReps[ CurrentRep ].front().first - ThisRep.front().first, DistinctReps[ CurrentRep ].front().second - ThisRep.front().second);
unsigned int CurrentSite = 1;
while( Shifted && CurrentSite < DistinctReps[ CurrentRep ].size())
{
Shifted = Shifted && ((shift.first == (DistinctReps[ CurrentRep ][ CurrentSite ].first - ThisRep[ CurrentSite ].first)) && (shift.second == (DistinctReps[ CurrentRep ][ CurrentSite ].second - ThisRep[ CurrentSite ].second)));
CurrentSite++;
}
GlobalShifted = GlobalShifted || Shifted;
}
if ( !GlobalShifted )
{
const std::pair< int, int> shift = std::make_pair(-ThisRep.front().first, -ThisRep.front().second);
for( unsigned int CurrentSite = 0; CurrentSite < ThisRep.size(); CurrentSite++)
{
ThisRep[ CurrentSite ].first += shift.first;
ThisRep[ CurrentSite ].second += shift.second;
}
DistinctReps.push_back(ThisRep);
}
}
//! [Double vector site index find subgraphs reps]
//Now we have all distinct permutations of the graph!
//! [Double vector site index find subgraphs shift count]
int Embeddings = 0;
for( unsigned int CurrentRep = 0; CurrentRep < DistinctReps.size(); CurrentRep++)
{
std::pair< int, int> shift = std::make_pair(0,0);
int xMax = 0;
int xMin = 0;
int yMax = 0;
int yMin = 0;
for( unsigned int CurrentElement = 0; CurrentElement < GraphList[ CurrentGraphHeight ][ gid ].Sites.size(); CurrentElement++)
{
xMax = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first > xMax) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first : xMax;
yMax = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second > yMax) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second : yMax;
xMin = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first < xMin) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].first : xMin;
yMin = (GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second < yMin) ? GraphList[ CurrentGraphHeight ][ gid ].Sites[ CurrentElement ].second : yMin;
}
for( int xBoost = xMin; xBoost <= xMax; xBoost++)
{
for( int yBoost = yMin; yBoost <= yMax; yBoost++)
{
shift = std::make_pair(xBoost, yBoost);
std::vector< std::pair< int, int> > CheckList = DistinctReps[ CurrentRep ];
unsigned int Counter = 0;
for( unsigned int CurrentSite = 0; CurrentSite < DistinctReps[ CurrentRep ].size(); CurrentSite++)
{
CheckList[ CurrentSite ].first += shift.first;
CheckList[ CurrentSite ].second += shift.second;
Counter += std::binary_search(GraphList[ CurrentGraphHeight ][ gid ].Sites.begin(), GraphList[ CurrentGraphHeight ][ gid ].Sites.end(), CheckList[ CurrentSite ]);
}
if ( Counter == CheckList.size() )
{
Embeddings++;
}
}
}
}
if (Embeddings > 0)
{
GraphList[ CurrentGraphHeight ][ gid ].SubgraphList.push_back( std::make_pair(Embeddings, GraphList[ CurrentCheckHeight ][ CurrentCheckWidth ].Identifier));
}
//! [Double vector site index find subgraphs shift count]
}
}
}
}
}
}
}
void FindSubgraphs(vector< vector< BondGraph > > & GraphList)
{
for( unsigned int CurrentGraphHeight = 1; CurrentGraphHeight < GraphList.size(); CurrentGraphHeight++)
{
int tid;
int gid;
int MaxSize = omp_get_num_procs();
//! [Double vector bond find subgraphs search]
for( unsigned int CurrentGraphGroup = 0; CurrentGraphGroup*MaxSize <= GraphList[ CurrentGraphHeight ].size(); CurrentGraphGroup++)
{
omp_set_num_threads( MaxSize );
#pragma omp parallel private(tid, gid) shared(MaxSize, CurrentGraphGroup, CurrentGraphHeight)
{
tid = omp_get_thread_num();
gid = tid + (CurrentGraphGroup * MaxSize);
//! [Double vector bond find subgraphs search]
if( (unsigned int) gid < GraphList[ CurrentGraphHeight ].size() )
{
//! [Double vector bond find subgraphs single]
GraphList[ CurrentGraphHeight ][ gid ].SubgraphList.push_back(std::make_pair(GraphList[ CurrentGraphHeight ][ gid ].NumberSites(), 0));
//! [Double vector bond find subgraphs single]
for( unsigned int CurrentCheckHeight = 1; CurrentCheckHeight < CurrentGraphHeight; CurrentCheckHeight++ )