Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
43
Issues
43
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
b65db1f2
Commit
b65db1f2
authored
Aug 23, 2015
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
draw_hierarchy(): Improve efficiency of "hshortcuts" option
parent
61c4bfed
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
23 deletions
+20
-23
src/graph/draw/graph_cairo_draw.cc
src/graph/draw/graph_cairo_draw.cc
+1
-1
src/graph/draw/graph_tree_cts.cc
src/graph/draw/graph_tree_cts.cc
+8
-6
src/graph_tool/draw/cairo_draw.py
src/graph_tool/draw/cairo_draw.py
+11
-16
No files found.
src/graph/draw/graph_cairo_draw.cc
View file @
b65db1f2
...
...
@@ -2150,7 +2150,7 @@ struct enum_from_int
};
void
get_cts
(
GraphInterface
&
gi
,
GraphInterface
&
tgi
,
boost
::
any
otpos
,
boost
::
any
obeta
,
boost
::
any
octs
,
bool
);
boost
::
any
obeta
,
boost
::
any
octs
,
bool
,
size_t
);
BOOST_PYTHON_MODULE
(
libgraph_tool_draw
)
{
...
...
src/graph/draw/graph_tree_cts.cc
View file @
b65db1f2
...
...
@@ -128,7 +128,8 @@ void get_control_points(vector<size_t>& path, PosProp pos, double beta,
}
template
<
class
Graph
>
void
tree_path
(
Graph
&
g
,
size_t
s
,
size_t
t
,
vector
<
size_t
>&
path
)
void
tree_path
(
Graph
&
g
,
size_t
s
,
size_t
t
,
vector
<
size_t
>&
path
,
size_t
max_depth
)
{
vector
<
size_t
>
s_root
;
vector
<
size_t
>
t_root
;
...
...
@@ -138,7 +139,7 @@ void tree_path(Graph& g, size_t s, size_t t, vector<size_t>& path)
size_t
v
=
s
;
size_t
u
=
t
;
while
(
v
!=
u
)
while
(
v
!=
u
&&
s_root
.
size
()
<
max_depth
)
{
typename
graph_traits
<
Graph
>::
in_edge_iterator
e
,
e_end
;
tie
(
e
,
e_end
)
=
in_edges
(
v
,
g
);
...
...
@@ -200,7 +201,8 @@ void pack(vector<point_t>& cp, vector<T>& ncp)
struct
do_get_cts
{
template
<
class
Graph
,
class
Tree
,
class
PosProp
,
class
BProp
,
class
CMap
>
void
operator
()(
Graph
&
g
,
Tree
*
t
,
PosProp
tpos
,
BProp
beta
,
CMap
cts
,
bool
is_tree
)
const
void
operator
()(
Graph
&
g
,
Tree
*
t
,
PosProp
tpos
,
BProp
beta
,
CMap
cts
,
bool
is_tree
,
size_t
max_depth
)
const
{
vector
<
size_t
>
path
;
vector
<
point_t
>
cp
;
...
...
@@ -215,7 +217,7 @@ struct do_get_cts
path
.
clear
();
if
(
is_tree
)
tree_path
(
*
t
,
u
,
v
,
path
);
tree_path
(
*
t
,
u
,
v
,
path
,
max_depth
);
else
graph_path
(
*
t
,
u
,
v
,
path
);
cp
.
clear
();
...
...
@@ -239,7 +241,7 @@ struct get_pointers
};
void
get_cts
(
GraphInterface
&
gi
,
GraphInterface
&
tgi
,
boost
::
any
otpos
,
boost
::
any
obeta
,
boost
::
any
octs
,
bool
is_tree
)
boost
::
any
obeta
,
boost
::
any
octs
,
bool
is_tree
,
size_t
max_depth
)
{
typedef
property_map_type
::
apply
<
vector
<
double
>
,
GraphInterface
::
edge_index_map_t
>::
type
...
...
@@ -253,7 +255,7 @@ void get_cts(GraphInterface& gi, GraphInterface& tgi, boost::any otpos,
run_action
<>
()
(
gi
,
std
::
bind
(
do_get_cts
(),
placeholders
::
_1
,
placeholders
::
_2
,
placeholders
::
_3
,
beta
,
cts
,
is_tree
),
placeholders
::
_3
,
beta
,
cts
,
is_tree
,
max_depth
),
get_pointers
::
apply
<
graph_tool
::
detail
::
always_directed
>::
type
(),
vertex_scalar_vector_properties
())
(
tgi
.
GetGraphView
(),
otpos
);
...
...
src/graph_tool/draw/cairo_draw.py
View file @
b65db1f2
...
...
@@ -1226,7 +1226,8 @@ def transform_scale(M, scale):
scale
/
np
.
sqrt
(
2
))
return
np
.
sqrt
(
p
[
0
]
**
2
+
p
[
1
]
**
2
)
def
get_hierarchy_control_points
(
g
,
t
,
tpos
,
beta
=
0.8
,
cts
=
None
,
is_tree
=
True
):
def
get_hierarchy_control_points
(
g
,
t
,
tpos
,
beta
=
0.8
,
cts
=
None
,
is_tree
=
True
,
max_depth
=
None
):
r
"""Return the Bézier spline control points for the edges in ``g``, given the hierarchical structure encoded in graph `t`.
Parameters
...
...
@@ -1253,6 +1254,9 @@ def get_hierarchy_control_points(g, t, tpos, beta=0.8, cts=None, is_tree=True):
is_tree : ``bool`` (optional, default: ``True``)
If ``True``, ``t`` must be a directed tree, otherwise it can be any
connected graph.
max_depth : ``int`` (optional, default: ``None``)
If supplied, only the first ``max_depth`` bottom levels of the hierarchy
will be used.
Returns
...
...
@@ -1326,13 +1330,16 @@ def get_hierarchy_control_points(g, t, tpos, beta=0.8, cts=None, is_tree=True):
else
:
beta
=
beta
.
copy
(
"double"
)
if
max_depth
is
None
:
max_depth
=
t
.
num_vertices
()
tu
=
GraphView
(
tu
,
skip_vfilt
=
True
)
libgraph_tool_draw
.
get_cts
(
u
.
_Graph__graph
,
tu
.
_Graph__graph
,
_prop
(
"v"
,
tu
,
tpos
),
_prop
(
"e"
,
u
,
beta
),
_prop
(
"e"
,
u
,
cts
),
is_tree
)
is_tree
,
max_depth
)
return
cts
#
...
...
@@ -1590,24 +1597,13 @@ def draw_hierarchy(state, pos=None, layout="radial", beta=0.8, ealpha=0.4,
dist
=
shortest_distance
(
t
,
source
=
root
)
hvvisible
.
fa
=
dist
.
fa
>=
hide
hevisible
=
t
.
new_edge_property
(
"bool"
,
True
)
if
hshortcuts
>
0
:
root
=
t
.
vertex
(
t
.
num_vertices
()
-
1
)
dist
=
shortest_distance
(
t
,
source
=
root
)
nodes
=
[
v
for
v
in
t
.
vertices
()
if
dist
[
v
]
<=
hshortcuts
]
for
v
in
nodes
:
for
u
in
nodes
:
if
u
==
v
:
continue
t
.
add_edge
(
u
,
v
)
pos
=
g
.
own_property
(
tpos
.
copy
())
if
verbose
:
print
(
"getting cts..."
)
cts
=
get_hierarchy_control_points
(
g
,
t
,
tpos
,
beta
,
is_tree
=
hshortcuts
==
0
)
max_depth
=
len
(
state
.
levels
)
-
hshortcuts
)
if
verbose
:
print
(
"done."
)
...
...
@@ -1679,8 +1675,7 @@ def draw_hierarchy(state, pos=None, layout="radial", beta=0.8, ealpha=0.4,
t_orig
=
t
t
=
GraphView
(
t
,
vfilt
=
lambda
v
:
int
(
v
)
>=
g
.
num_vertices
(
True
)
and
hvvisible
[
v
],
efilt
=
hevisible
)
vfilt
=
lambda
v
:
int
(
v
)
>=
g
.
num_vertices
(
True
)
and
hvvisible
[
v
])
if
verbose
:
print
(
"joining graphs"
)
props
=
[(
pos
,
tpos
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment