Skip to content

Commit cdc3cc0

Browse files
committed
done
1 parent 57d15c1 commit cdc3cc0

File tree

11 files changed

+568
-22
lines changed

11 files changed

+568
-22
lines changed

Diff for: FindCycleInGraph/main.cpp

-15
This file was deleted.

Diff for: FindCycleInGraph.xcodeproj/project.pbxproj renamed to FindCycleInGraphAndShortestWay.xcodeproj/project.pbxproj

+27-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
/* Begin PBXBuildFile section */
1010
F5FE29A421F14A1B00A21304 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FE29A321F14A1B00A21304 /* main.cpp */; };
11+
F5FE29AC21F15D8500A21304 /* Graph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FE29AA21F15D8500A21304 /* Graph.cpp */; };
12+
F5FE29B021F40BD200A21304 /* GraphAlghorithms.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FE29AE21F40BD200A21304 /* GraphAlghorithms.cpp */; };
1113
/* End PBXBuildFile section */
1214

1315
/* Begin PBXCopyFilesBuildPhase section */
@@ -25,6 +27,9 @@
2527
/* Begin PBXFileReference section */
2628
F5FE29A021F14A1B00A21304 /* FindCycleInGraph */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = FindCycleInGraph; sourceTree = BUILT_PRODUCTS_DIR; };
2729
F5FE29A321F14A1B00A21304 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
30+
F5FE29AA21F15D8500A21304 /* Graph.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Graph.cpp; sourceTree = "<group>"; };
31+
F5FE29AB21F15D8500A21304 /* Graph.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Graph.hpp; sourceTree = "<group>"; };
32+
F5FE29AE21F40BD200A21304 /* GraphAlghorithms.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphAlghorithms.cpp; sourceTree = "<group>"; };
2833
/* End PBXFileReference section */
2934

3035
/* Begin PBXFrameworksBuildPhase section */
@@ -41,7 +46,7 @@
4146
F5FE299721F14A1B00A21304 = {
4247
isa = PBXGroup;
4348
children = (
44-
F5FE29A221F14A1B00A21304 /* FindCycleInGraph */,
49+
F5FE29A221F14A1B00A21304 /* FindCycleInGraphAndShortestWay */,
4550
F5FE29A121F14A1B00A21304 /* Products */,
4651
);
4752
sourceTree = "<group>";
@@ -54,12 +59,23 @@
5459
name = Products;
5560
sourceTree = "<group>";
5661
};
57-
F5FE29A221F14A1B00A21304 /* FindCycleInGraph */ = {
62+
F5FE29A221F14A1B00A21304 /* FindCycleInGraphAndShortestWay */ = {
5863
isa = PBXGroup;
5964
children = (
6065
F5FE29A321F14A1B00A21304 /* main.cpp */,
66+
F5FE29AD21F40B6500A21304 /* Graph */,
6167
);
62-
path = FindCycleInGraph;
68+
path = FindCycleInGraphAndShortestWay;
69+
sourceTree = "<group>";
70+
};
71+
F5FE29AD21F40B6500A21304 /* Graph */ = {
72+
isa = PBXGroup;
73+
children = (
74+
F5FE29AA21F15D8500A21304 /* Graph.cpp */,
75+
F5FE29AB21F15D8500A21304 /* Graph.hpp */,
76+
F5FE29AE21F40BD200A21304 /* GraphAlghorithms.cpp */,
77+
);
78+
path = Graph;
6379
sourceTree = "<group>";
6480
};
6581
/* End PBXGroup section */
@@ -96,7 +112,7 @@
96112
};
97113
};
98114
};
99-
buildConfigurationList = F5FE299B21F14A1B00A21304 /* Build configuration list for PBXProject "FindCycleInGraph" */;
115+
buildConfigurationList = F5FE299B21F14A1B00A21304 /* Build configuration list for PBXProject "FindCycleInGraphAndShortestWay" */;
100116
compatibilityVersion = "Xcode 9.3";
101117
developmentRegion = en;
102118
hasScannedForEncodings = 0;
@@ -118,7 +134,9 @@
118134
isa = PBXSourcesBuildPhase;
119135
buildActionMask = 2147483647;
120136
files = (
137+
F5FE29AC21F15D8500A21304 /* Graph.cpp in Sources */,
121138
F5FE29A421F14A1B00A21304 /* main.cpp in Sources */,
139+
F5FE29B021F40BD200A21304 /* GraphAlghorithms.cpp in Sources */,
122140
);
123141
runOnlyForDeploymentPostprocessing = 0;
124142
};
@@ -131,7 +149,7 @@
131149
ALWAYS_SEARCH_USER_PATHS = NO;
132150
CLANG_ANALYZER_NONNULL = YES;
133151
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
134-
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
152+
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
135153
CLANG_CXX_LIBRARY = "libc++";
136154
CLANG_ENABLE_MODULES = YES;
137155
CLANG_ENABLE_OBJC_ARC = YES;
@@ -190,7 +208,7 @@
190208
ALWAYS_SEARCH_USER_PATHS = NO;
191209
CLANG_ANALYZER_NONNULL = YES;
192210
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
193-
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
211+
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
194212
CLANG_CXX_LIBRARY = "libc++";
195213
CLANG_ENABLE_MODULES = YES;
196214
CLANG_ENABLE_OBJC_ARC = YES;
@@ -239,6 +257,7 @@
239257
F5FE29A821F14A1B00A21304 /* Debug */ = {
240258
isa = XCBuildConfiguration;
241259
buildSettings = {
260+
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
242261
CODE_SIGN_STYLE = Automatic;
243262
PRODUCT_NAME = "$(TARGET_NAME)";
244263
};
@@ -247,6 +266,7 @@
247266
F5FE29A921F14A1B00A21304 /* Release */ = {
248267
isa = XCBuildConfiguration;
249268
buildSettings = {
269+
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
250270
CODE_SIGN_STYLE = Automatic;
251271
PRODUCT_NAME = "$(TARGET_NAME)";
252272
};
@@ -255,7 +275,7 @@
255275
/* End XCBuildConfiguration section */
256276

257277
/* Begin XCConfigurationList section */
258-
F5FE299B21F14A1B00A21304 /* Build configuration list for PBXProject "FindCycleInGraph" */ = {
278+
F5FE299B21F14A1B00A21304 /* Build configuration list for PBXProject "FindCycleInGraphAndShortestWay" */ = {
259279
isa = XCConfigurationList;
260280
buildConfigurations = (
261281
F5FE29A521F14A1B00A21304 /* Debug */,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
type = "1"
4+
version = "2.0">
5+
<Breakpoints>
6+
<BreakpointProxy
7+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
8+
<BreakpointContent
9+
shouldBeEnabled = "No"
10+
ignoreCount = "0"
11+
continueAfterRunningActions = "No"
12+
filePath = "FindCycleInGraph/Graph/GraphAlghorithms.cpp"
13+
timestampString = "571014335.374163"
14+
startingColumnNumber = "9223372036854775807"
15+
endingColumnNumber = "9223372036854775807"
16+
startingLineNumber = "72"
17+
endingLineNumber = "72"
18+
landmarkName = "find(const Graph&amp; graph, const size_t from, const size_t to)"
19+
landmarkType = "9">
20+
</BreakpointContent>
21+
</BreakpointProxy>
22+
<BreakpointProxy
23+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24+
<BreakpointContent
25+
shouldBeEnabled = "No"
26+
ignoreCount = "0"
27+
continueAfterRunningActions = "No"
28+
filePath = "FindCycleInGraph/Graph/GraphAlghorithms.cpp"
29+
timestampString = "571014335.376382"
30+
startingColumnNumber = "9223372036854775807"
31+
endingColumnNumber = "9223372036854775807"
32+
startingLineNumber = "93"
33+
endingLineNumber = "93"
34+
landmarkName = "subFunctionFind(const Graph&amp; graph, Collections&amp; collections, const size_t destination)"
35+
landmarkType = "9">
36+
</BreakpointContent>
37+
</BreakpointProxy>
38+
<BreakpointProxy
39+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
40+
<BreakpointContent
41+
shouldBeEnabled = "Yes"
42+
ignoreCount = "0"
43+
continueAfterRunningActions = "No"
44+
filePath = "FindCycleInGraph/Graph/GraphAlghorithms.cpp"
45+
timestampString = "571014335.376763"
46+
startingColumnNumber = "9223372036854775807"
47+
endingColumnNumber = "9223372036854775807"
48+
startingLineNumber = "129"
49+
endingLineNumber = "129"
50+
landmarkName = "findReturnTrip(Vector&amp; way, const ReturnTrip&amp; trip, const size_t destination)"
51+
landmarkType = "9">
52+
</BreakpointContent>
53+
</BreakpointProxy>
54+
<BreakpointProxy
55+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
56+
<BreakpointContent
57+
shouldBeEnabled = "No"
58+
ignoreCount = "0"
59+
continueAfterRunningActions = "No"
60+
filePath = "FindCycleInGraph/Graph/GraphAlghorithms.cpp"
61+
timestampString = "571014335.377121"
62+
startingColumnNumber = "9223372036854775807"
63+
endingColumnNumber = "9223372036854775807"
64+
startingLineNumber = "110"
65+
endingLineNumber = "110"
66+
landmarkName = "subFunctionFind(const Graph&amp; graph, Collections&amp; collections, const size_t destination)"
67+
landmarkType = "9">
68+
</BreakpointContent>
69+
</BreakpointProxy>
70+
</Breakpoints>
71+
</Bucket>

Diff for: FindCycleInGraphAndShortestWay/Graph/Graph.cpp

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// Graph.cpp
3+
// FindCycleInGraph
4+
//
5+
// Created by vlad on 18.01.2019.
6+
// Copyright © 2019 vlad. All rights reserved.
7+
//
8+
#ifndef Graph_cpp
9+
#define Graph_cpp
10+
11+
#include "Graph.hpp"
12+
#include <iostream>
13+
14+
//Constructors
15+
template<class Element>
16+
Math::Graph<Element>::Graph(std::initializer_list<unsigned>&& list){
17+
const auto square = Utilities::isSquare(list.size());
18+
assert(square);
19+
auto size = std::move(*square);
20+
this->size = size;
21+
for(size_t rawNumber = 0;rawNumber<size;++rawNumber){
22+
vector raw(size);
23+
auto beginOfRaw = list.begin()+size*rawNumber;
24+
std::copy(beginOfRaw,beginOfRaw+size, raw.begin());
25+
graph.push_back(std::move(raw));
26+
}
27+
28+
}
29+
30+
31+
//VERTEX
32+
template<class Element>
33+
template<class ValueType>
34+
void Math::Graph<Element>::addVertex(ValueType&& value){
35+
constexpr auto isSame = Utilities::RemoveReferenceAndCompareTypes<ValueType, Element>();
36+
static_assert(isSame, "Different types!");
37+
++size;
38+
//update matrix
39+
vector newRaw(size,false);
40+
graph.push_back(std::move(newRaw));
41+
for (size_t index = 0; index < size-1; ++index) graph[index].push_back(false);
42+
//update labels
43+
labels.push_back(std::forward<ValueType>(value));
44+
}
45+
46+
//EDGE
47+
template<class Element>
48+
template<class Indecies>
49+
void Math::Graph<Element>::addEdge(Indecies&& source,Indecies&& to){
50+
assert(source < size &&
51+
to < size);
52+
graph[source][to] = true;
53+
}
54+
55+
56+
57+
//OUTPUT
58+
template<class Element>
59+
void Math::Graph<Element>::outputGraph()const{
60+
std::cout<<"WAYS"<< std::endl;
61+
for(const auto& raw :graph){
62+
for(const auto element : raw)
63+
std::cout << element << " ";
64+
std::cout<<std::endl;
65+
}
66+
std::cout<<"VALUES"<< std::endl;
67+
68+
for (size_t index = 0; index < labels.size(); ++index) {
69+
std::cout << "Vertex "<<index << ": "
70+
<< labels[index] << " "<<std::endl;
71+
}
72+
}
73+
74+
template<class Element>
75+
size_t Math::Graph<Element>::getSize()const{
76+
return graph.size();
77+
}
78+
79+
#endif /* Graph_cpp */

0 commit comments

Comments
 (0)