Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hpp-manipulation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Humanoid Path Planner
hpp-manipulation
Commits
c887843b
Commit
c887843b
authored
10 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add method Graph::getEdge
parent
abb8d5c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/hpp/manipulation/graph/graph.hh
+3
-0
3 additions, 0 deletions
include/hpp/manipulation/graph/graph.hh
src/graph/graph.cc
+67
-0
67 additions, 0 deletions
src/graph/graph.cc
with
70 additions
and
0 deletions
include/hpp/manipulation/graph/graph.hh
+
3
−
0
View file @
c887843b
...
...
@@ -47,6 +47,9 @@ namespace hpp {
/// Returns the states of a configuration.
Nodes_t
getNode
(
const
Configuration_t
config
)
const
;
/// Get possible edges between two nodes.
std
::
vector
<
Edges_t
>
getEdge
(
const
Nodes_t
&
from
,
const
Nodes_t
&
to
)
const
;
/// Select randomly outgoing edges of the given nodes.
Edges_t
chooseEdge
(
const
Nodes_t
&
node
)
const
;
...
...
This diff is collapsed.
Click to expand it.
src/graph/graph.cc
+
67
−
0
View file @
c887843b
...
...
@@ -82,6 +82,73 @@ namespace hpp {
return
nodes
;
}
static
void
buildPossibleEdges
(
Edges_t
current
,
const
std
::
vector
<
Edges_t
>&
edgesPerNodeSelector
,
std
::
vector
<
Edges_t
>&
possibleEdges
)
{
size_t
d
=
current
.
size
();
if
(
d
==
edgesPerNodeSelector
.
size
())
{
possibleEdges
.
push_back
(
current
);
return
;
}
Edges_t
::
const_iterator
it
=
edgesPerNodeSelector
[
d
].
begin
();
while
(
it
!=
edgesPerNodeSelector
[
d
].
end
())
{
current
.
push_back
(
*
it
);
buildPossibleEdges
(
current
,
edgesPerNodeSelector
,
possibleEdges
);
current
.
pop_back
();
it
++
;
}
}
std
::
vector
<
Edges_t
>
Graph
::
getEdge
(
const
Nodes_t
&
from
,
const
Nodes_t
&
to
)
const
{
assert
(
from
.
size
()
==
to
.
size
());
assert
(
nodeSelectors_
.
size
()
==
to
.
size
());
size_t
numberPossibleEdges
=
1
;
std
::
vector
<
Edges_t
>
edgesPerNodeSelector
(
nodeSelectors_
.
size
());
std
::
vector
<
Edges_t
>::
iterator
itEdgePerNodeSelector
=
edgesPerNodeSelector
.
begin
();
Nodes_t
::
const_iterator
itFrom
=
from
.
begin
(),
itTo
=
to
.
begin
();
// We first iterate through from. For each element of from,
// we look for all edges between this element of from and its corresponding
// element in to. The resulting set of Edges_t is stored in
// edgesPerNodeSelector.
// Temporary variable.
Edges_t
edgesInNodeSelector
;
const
Edges_t
*
neighbors
;
Edges_t
::
const_iterator
itEdge
;
while
(
itFrom
!=
from
.
end
())
{
edgesInNodeSelector
.
clear
();
neighbors
=
&
((
*
itFrom
)
->
neighbors
());
itEdge
=
neighbors
->
begin
();
// Find the edges between *itFrom and *itTo
while
(
itEdge
!=
neighbors
->
end
())
{
if
(
(
*
itEdge
)
->
to
()
==
(
*
itTo
)
)
edgesInNodeSelector
.
push_back
(
*
itEdge
);
itEdge
++
;
}
/// If no Edge is found, the two Node are not connected.
if
(
edgesInNodeSelector
.
empty
())
return
std
::
vector
<
Edges_t
>
(
0
);
// Store the Edges.
numberPossibleEdges
*=
edgesInNodeSelector
.
size
();
*
itEdgePerNodeSelector
=
edgesInNodeSelector
;
itFrom
++
;
itTo
++
;
itEdgePerNodeSelector
++
;
}
assert
(
itTo
==
to
.
end
());
assert
(
itEdgePerNodeSelector
==
edgesPerNodeSelector
.
end
());
// Now, we can create the list of possible Edges_t
// between from and to.
std
::
vector
<
Edges_t
>
possibleEdges
;
buildPossibleEdges
(
Edges_t
(),
edgesPerNodeSelector
,
possibleEdges
);
assert
(
possibleEdges
.
size
()
==
numberPossibleEdges
);
return
possibleEdges
;
}
Edges_t
Graph
::
chooseEdge
(
const
Nodes_t
&
nodes
)
const
{
Edges_t
edges
;
...
...
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