Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-istl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-istl
Commits
5b2950cb
Commit
5b2950cb
authored
20 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Edge in Subgraph are ordered by target to make binary search possible.
[[Imported from SVN: r163]]
parent
d10a3fb7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
istl/paamg/graph.hh
+94
-27
94 additions, 27 deletions
istl/paamg/graph.hh
with
94 additions
and
27 deletions
istl/paamg/graph.hh
+
94
−
27
View file @
5b2950cb
...
...
@@ -7,6 +7,8 @@
#include
<iostream>
#include
<vector>
#include
<dune/common/typetraits.hh>
#include
<dune/common/iteratorfacades.hh>
namespace
Dune
{
namespace
amg
...
...
@@ -137,6 +139,8 @@ namespace Dune
/** @brief The index of the source vertex of the current edge. */
VertexDescriptor
source
()
const
;
/** @brief Get the offste to the first edge starting at the same vertex. */
int
offset
()
const
;
private
:
/** @brief Start vertex of the edges. */
...
...
@@ -379,7 +383,7 @@ namespace Dune
/**
* @brief The edge iterator of the graph.
*/
class
EdgeIterator
class
EdgeIterator
:
public
RandomAccessIteratorFacade
<
EdgeIterator
,
const
VertexDescriptor
>
{
public:
/**
...
...
@@ -387,28 +391,51 @@ namespace Dune
* @param source The source vertex of the edge.
* @param target The edge the iterator is positioned on.
*/
EdgeIterator
(
const
VertexDescriptor
&
source
,
EdgeDescriptor
targe
t
);
EdgeIterator
(
const
VertexDescriptor
&
source
,
std
::
ptrdiff_t
offset
,
EdgeDescriptor
firs
t
);
/** @brief
Ine
quality operator. */
bool
operator
!=
(
const
EdgeIterator
&
other
)
const
;
/** @brief
E
quality operator. */
bool
equals
(
const
EdgeIterator
&
other
)
const
;
/** @brief Equality operator. */
bool
operator
==
(
const
EdgeIterator
&
other
)
const
;
//
bool operator==(const EdgeIterator& other) const;
/** @brief Preincrement operator. */
EdgeIterator
&
operator
++
();
EdgeIterator
&
increment
();
/** @brief Preincrement operator. */
EdgeIterator
&
decrement
();
EdgeIterator
&
advance
(
std
::
ptrdiff_t
n
);
/** @brief The index of the target vertex of the current edge. */
VertexDescriptor
target
()
const
;
const
VertexDescriptor
&
dereference
()
const
;
/** @brief The index of the target vertex of the current edge. */
const
VertexDescriptor
&
target
()
const
;
/** @brief The index of the source vertex of the current edge. */
VertexDescriptor
source
()
const
;
const
VertexDescriptor
&
source
()
const
;
std
::
ptrdiff_t
distanceTo
(
const
EdgeIterator
&
other
)
const
;
/**
* @brief Get the offset of the edge to the first edge of the graph.
* @return The sum of all the edges starting from a vertex that
* is smaller than the source vertex plus the distance to the first
* edge starting at the source vertex.
*/
std
::
ptrdiff_t
offset
()
const
;
private:
/** @brief The source vertex of the edge. */
VertexDescriptor
source_
;
/** @brief The target vertex of the edge. */
EdgeDescriptor
target_
;
/**
* @brief The offset of the current edge to the first
* one starting at the vertex source_.
*/
std
::
ptrdiff_t
offset_
;
/** @brief The first edge of the graph starting at source_. */
const
EdgeDescriptor
first_
;
};
/**
...
...
@@ -1200,6 +1227,13 @@ namespace Dune
return
source_
;
}
template
<
class
M
>
template
<
class
C
>
inline
int
MatrixGraph
<
M
>::
EdgeIteratorT
<
C
>::
offset
()
const
{
return
block_
.
offset
();
}
template
<
class
M
>
template
<
class
C
>
MatrixGraph
<
M
>::
VertexIteratorT
<
C
>::
VertexIteratorT
(
C
*
graph
,
...
...
@@ -1352,39 +1386,71 @@ namespace Dune
template
<
class
G
>
SubGraph
<
G
>::
EdgeIterator
::
EdgeIterator
(
const
VertexDescriptor
&
source
,
EdgeDescriptor
targe
t
)
:
source_
(
source
),
target_
(
targe
t
)
std
::
ptrdiff_t
offset
,
const
EdgeDescriptor
firs
t
)
:
source_
(
source
),
offset_
(
offset
),
first_
(
firs
t
)
{}
template
<
class
G
>
bool
SubGraph
<
G
>::
EdgeIterator
::
operator
==
(
const
EdgeIterator
&
other
)
const
bool
SubGraph
<
G
>::
EdgeIterator
::
equals
(
const
EdgeIterator
&
other
)
const
{
return
other
.
targ
et_
==
targ
et_
;
return
other
.
offs
et_
==
offs
et_
;
}
/*
template<class G>
bool SubGraph<G>::EdgeIterator::operator!=(const EdgeIterator& other) const
{
return other.target_!=target_;
}
*/
template
<
class
G
>
bool
SubGraph
<
G
>::
EdgeIterator
::
operator
!=
(
const
EdgeIterator
&
other
)
const
typename
SubGraph
<
G
>::
EdgeIterator
&
SubGraph
<
G
>::
EdgeIterator
::
increment
()
{
return
other
.
target_
!=
target_
;
++
offset_
;
return
*
this
;
}
template
<
class
G
>
typename
SubGraph
<
G
>::
EdgeIterator
&
SubGraph
<
G
>::
EdgeIterator
::
operator
++
()
typename
SubGraph
<
G
>::
EdgeIterator
&
SubGraph
<
G
>::
EdgeIterator
::
decrement
()
{
++
targ
et_
;
--
offs
et_
;
return
*
this
;
}
template
<
class
G
>
typename
G
::
VertexDescriptor
SubGraph
<
G
>::
EdgeIterator
::
source
()
const
typename
SubGraph
<
G
>::
EdgeIterator
&
SubGraph
<
G
>::
EdgeIterator
::
advance
(
std
::
ptrdiff_t
n
)
{
offset_
+=
n
;
return
*
this
;
}
template
<
class
G
>
const
typename
G
::
VertexDescriptor
&
SubGraph
<
G
>::
EdgeIterator
::
source
()
const
{
return
source_
;
}
template
<
class
G
>
typename
G
::
VertexDescriptor
SubGraph
<
G
>::
EdgeIterator
::
target
()
const
const
typename
G
::
VertexDescriptor
&
SubGraph
<
G
>::
EdgeIterator
::
target
()
const
{
return
first_
[
offset_
];
}
template
<
class
G
>
const
typename
G
::
VertexDescriptor
&
SubGraph
<
G
>::
EdgeIterator
::
dereference
()
const
{
return
*
first_
[
offset_
];
}
template
<
class
G
>
std
::
ptrdiff_t
SubGraph
<
G
>::
EdgeIterator
::
distanceTo
(
const
EdgeIterator
&
other
)
const
{
return
*
target_
;
return
other
.
offset_
-
offset_
;
}
template
<
class
G
>
std
::
ptrdiff_t
SubGraph
<
G
>::
EdgeIterator
::
offset
()
const
{
return
offset_
;
}
template
<
class
G
>
...
...
@@ -1462,13 +1528,13 @@ namespace Dune
template
<
class
G
>
typename
SubGraph
<
G
>::
EdgeIterator
SubGraph
<
G
>::
beginEdges
(
const
VertexDescriptor
&
source
)
const
{
return
EdgeIterator
(
source
,
edges_
+
start_
[
source
]);
return
EdgeIterator
(
source
,
0
,
edges_
+
start_
[
source
]);
}
template
<
class
G
>
typename
SubGraph
<
G
>::
EdgeIterator
SubGraph
<
G
>::
endEdges
(
const
VertexDescriptor
&
source
)
const
{
return
EdgeIterator
(
source
,
edges_
+
end
_
[
source
]);
return
EdgeIterator
(
source
,
end_
[
source
],
edges_
+
start
_
[
source
]);
}
template
<
class
G
>
...
...
@@ -1511,7 +1577,7 @@ namespace Dune
++
noVertices_
;
endVertex_
=
std
::
max
(
vertex
.
index
(),
endVertex_
);
start_
[
vertex
.
index
()]
=
end_
[
vertex
.
index
()]
=
edge
-
edges_
;
start_
[
vertex
.
index
()]
=
edge
-
edges_
;
typedef
typename
Graph
::
ConstEdgeIterator
Iterator
;
Iterator
endEdge
=
vertex
.
end
();
...
...
@@ -1520,11 +1586,12 @@ namespace Dune
if
(
!
excluded
[
iter
.
target
()])
{
*
edge
=
iter
.
target
();
++
edge
;
++
end_
[
vertex
.
index
()];
}
end_
[
vertex
.
index
()]
=
edge
-
(
edges_
+
start_
[
vertex
.
index
()]);
// Sort the edges
//
std::sort(edges_+start_[vertex.index()], edge
s_+end[vertex.index()]
);
std
::
sort
(
edges_
+
start_
[
vertex
.
index
()],
edge
);
}
noEdges_
=
edge
-
edges_
;
++
endVertex_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment