Skip to content

Commit 9ab859a

Browse files
committedMay 31, 2011
using only 'vertex/arc' notation
1 parent 6e0435a commit 9ab859a

File tree

5 files changed

+47
-47
lines changed

5 files changed

+47
-47
lines changed
 

‎src/analysis/network/qgsgraph.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* \file qgsgraph.cpp
14-
* \brief implementation QgsGraph, QgsGraphVertex, QgsGraphEdge
14+
* \brief implementation QgsGraph, QgsGraphVertex, QgsGraphArc
1515
*/
1616

1717
#include "qgsgraph.h"
@@ -32,30 +32,30 @@ int QgsGraph::addVertex( const QgsPoint& pt )
3232
return mGraphVertexes.size()-1;
3333
}
3434

35-
int QgsGraph::addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties )
35+
int QgsGraph::addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties )
3636
{
37-
QgsGraphEdge e;
37+
QgsGraphArc e;
3838

3939
e.mProperties = properties;
4040
e.mOut = outVertexIdx;
4141
e.mIn = inVertexIdx;
42-
mGraphEdges.push_back( e );
43-
int edgeIdx = mGraphEdges.size()-1;
42+
mGraphArc.push_back( e );
43+
int edgeIdx = mGraphArc.size()-1;
4444

45-
mGraphVertexes[ outVertexIdx ].mOutEdges.push_back( edgeIdx );
46-
mGraphVertexes[ inVertexIdx ].mInEdges.push_back( edgeIdx );
45+
mGraphVertexes[ outVertexIdx ].mOutArc.push_back( edgeIdx );
46+
mGraphVertexes[ inVertexIdx ].mInArc.push_back( edgeIdx );
4747

48-
return mGraphEdges.size()-1;
48+
return mGraphArc.size()-1;
4949
}
5050

5151
const QgsGraphVertex& QgsGraph::vertex( int idx ) const
5252
{
5353
return mGraphVertexes[ idx ];
5454
}
5555

56-
const QgsGraphEdge& QgsGraph::edge( int idx ) const
56+
const QgsGraphArc& QgsGraph::arc( int idx ) const
5757
{
58-
return mGraphEdges[ idx ];
58+
return mGraphArc[ idx ];
5959
}
6060

6161

@@ -64,9 +64,9 @@ int QgsGraph::vertexCount() const
6464
return mGraphVertexes.size();
6565
}
6666

67-
int QgsGraph::edgeCount() const
67+
int QgsGraph::arcCount() const
6868
{
69-
return mGraphEdges.size();
69+
return mGraphArc.size();
7070
}
7171

7272
int QgsGraph::findVertex( const QgsPoint& pt ) const
@@ -82,27 +82,27 @@ int QgsGraph::findVertex( const QgsPoint& pt ) const
8282
return -1;
8383
}
8484

85-
QgsGraphEdge::QgsGraphEdge()
85+
QgsGraphArc::QgsGraphArc()
8686
{
8787

8888
}
8989

90-
QVariant QgsGraphEdge::property(int i) const
90+
QVariant QgsGraphArc::property(int i) const
9191
{
9292
return mProperties[ i ];
9393
}
9494

95-
QVector< QVariant > QgsGraphEdge::properties() const
95+
QVector< QVariant > QgsGraphArc::properties() const
9696
{
9797
return mProperties;
9898
}
9999

100-
int QgsGraphEdge::in() const
100+
int QgsGraphArc::in() const
101101
{
102102
return mIn;
103103
}
104104

105-
int QgsGraphEdge::out() const
105+
int QgsGraphArc::out() const
106106
{
107107
return mOut;
108108
}
@@ -113,14 +113,14 @@ QgsGraphVertex::QgsGraphVertex( const QgsPoint& point )
113113

114114
}
115115

116-
QgsGraphEdgeList QgsGraphVertex::outEdges() const
116+
QgsGraphArcIdList QgsGraphVertex::outArc() const
117117
{
118-
return mOutEdges;
118+
return mOutArc;
119119
}
120120

121-
QgsGraphEdgeList QgsGraphVertex::inEdges() const
121+
QgsGraphArcIdList QgsGraphVertex::inArc() const
122122
{
123-
return mInEdges;
123+
return mInArc;
124124
}
125125

126126
QgsPoint QgsGraphVertex::point() const

‎src/analysis/network/qgsgraph.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class QgsGraphVertex;
3838
* \class QgsGraphEdge
3939
* \brief This class implement a graph edge
4040
*/
41-
class ANALYSIS_EXPORT QgsGraphEdge
41+
class ANALYSIS_EXPORT QgsGraphArc
4242
{
4343
public:
44-
QgsGraphEdge();
44+
QgsGraphArc();
4545

4646
/**
4747
* return property value
@@ -75,7 +75,7 @@ class ANALYSIS_EXPORT QgsGraphEdge
7575
};
7676

7777

78-
typedef QList< int > QgsGraphEdgeList;
78+
typedef QList< int > QgsGraphArcIdList;
7979

8080
/**
8181
* \ingroup analysis
@@ -99,12 +99,12 @@ class ANALYSIS_EXPORT QgsGraphVertex
9999
/**
100100
* return outgoing edges
101101
*/
102-
QgsGraphEdgeList outEdges() const;
102+
QgsGraphArcIdList outArc() const;
103103

104104
/**
105105
* return incoming edges
106106
*/
107-
QgsGraphEdgeList inEdges() const;
107+
QgsGraphArcIdList inArc() const;
108108

109109
/**
110110
* return vertex point
@@ -113,8 +113,8 @@ class ANALYSIS_EXPORT QgsGraphVertex
113113

114114
private:
115115
QgsPoint mCoordinate;
116-
QgsGraphEdgeList mOutEdges;
117-
QgsGraphEdgeList mInEdges;
116+
QgsGraphArcIdList mOutArc;
117+
QgsGraphArcIdList mInArc;
118118

119119
friend class QgsGraph;
120120
};
@@ -141,7 +141,7 @@ class ANALYSIS_EXPORT QgsGraph
141141
/**
142142
* add edge to a graph
143143
*/
144-
int addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties );
144+
int addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties );
145145

146146
/**
147147
* retrun vertex count
@@ -156,12 +156,12 @@ class ANALYSIS_EXPORT QgsGraph
156156
/**
157157
* retrun edge count
158158
*/
159-
int edgeCount() const;
159+
int arcCount() const;
160160

161161
/**
162162
* retrun edge at index
163163
*/
164-
const QgsGraphEdge& edge( int idx ) const;
164+
const QgsGraphArc& arc( int idx ) const;
165165

166166
/**
167167
* find vertex by point
@@ -172,7 +172,7 @@ class ANALYSIS_EXPORT QgsGraph
172172
private:
173173
QVector<QgsGraphVertex> mGraphVertexes;
174174

175-
QVector<QgsGraphEdge> mGraphEdges;
175+
QVector<QgsGraphArc> mGraphArc;
176176
};
177177

178178
#endif //QGSGRAPHH

‎src/analysis/network/qgsgraphanalyzer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
3434
QMap< double, int > not_begin;
3535
QMap< double, int >::iterator it;
3636

37-
// QVector< QPair< cost, edge id > result
37+
// QVector< QPair< cost, arc id > result
3838
QVector< QPair< double, int > > result;
3939

4040
result.reserve( source->vertexCount() );
@@ -56,17 +56,17 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
5656
not_begin.erase( it );
5757

5858
// edge index list
59-
QgsGraphEdgeList l = source->vertex( curVertex ).outEdges();
60-
QgsGraphEdgeList::iterator edgeIt;
61-
for ( edgeIt = l.begin(); edgeIt != l.end(); ++edgeIt )
59+
QgsGraphArcIdList l = source->vertex( curVertex ).outArc();
60+
QgsGraphArcIdList::iterator arcIt;
61+
for ( arcIt = l.begin(); arcIt != l.end(); ++arcIt )
6262
{
63-
const QgsGraphEdge& edge = source->edge( *edgeIt );
64-
double cost = edge.property( criterionNum ).toDouble() + curCost;
63+
const QgsGraphArc& arc = source->arc( *arcIt );
64+
double cost = arc.property( criterionNum ).toDouble() + curCost;
6565

66-
if ( cost < result[ edge.in() ].first )
66+
if ( cost < result[ arc.in() ].first )
6767
{
68-
result[ edge.in() ] = QPair< double, int >( cost, *edgeIt );
69-
not_begin.insert( cost, edge.in() );
68+
result[ arc.in() ] = QPair< double, int >( cost, *arcIt );
69+
not_begin.insert( cost, arc.in() );
7070
}
7171
}
7272
}
@@ -88,10 +88,10 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
8888
{
8989
if ( result[ i ].first < std::numeric_limits<double>::infinity() && result[i].second != -1)
9090
{
91-
const QgsGraphEdge& edge = source->edge( result[i].second );
91+
const QgsGraphArc& arc = source->arc( result[i].second );
9292

93-
treeResult->addEdge( source2result[ edge.out() ], source2result[ i ],
94-
edge.properties() );
93+
treeResult->addArc( source2result[ arc.out() ], source2result[ i ],
94+
arc.properties() );
9595
}
9696
}
9797
}

‎src/analysis/network/qgsgraphbuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void QgsGraphBuilder::addVertex( int, const QgsPoint& pt )
4040

4141
void QgsGraphBuilder::addArc( int pt1id, const QgsPoint&, int pt2id, const QgsPoint&, const QVector< QVariant >& prop )
4242
{
43-
mGraph->addEdge( pt1id, pt2id, prop );
43+
mGraph->addArc( pt1id, pt2id, prop );
4444
}
4545

4646
QgsGraph* QgsGraphBuilder::graph()

‎src/plugins/roadgraph/shortestpathwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ void RgShortestPathWidget::findingPath()
316316
QList< QgsPoint > p;
317317
while( startVertexIdx != stopVertexIdx )
318318
{
319-
QgsGraphEdgeList l = path.vertex( stopVertexIdx ).inEdges();
319+
QgsGraphArcIdList l = path.vertex( stopVertexIdx ).inArc();
320320
if ( l.empty() )
321321
break;
322-
const QgsGraphEdge& e = path.edge( l.front() );
322+
const QgsGraphArc& e = path.arc( l.front() );
323323

324324
cost += e.property(0).toDouble();
325325
time += e.property(1).toDouble();

0 commit comments

Comments
 (0)