Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
d2d47234
Commit
d2d47234
authored
Nov 21, 2012
by
Tiago Peixoto
Browse files
Introduce new property type: int16_t (short)
parent
01d9c519
Changes
6
Hide whitespace changes
Inline
Side-by-side
doc/quickstart.rst
View file @
d2d47234
...
...
@@ -305,12 +305,14 @@ set:
Type name Alias
======================== ======================
``bool`` ``uint8_t``
``int16_t`` ``short``
``int32_t`` ``int``
``int64_t`` ``long``, ``long long``
``double`` ``float``
``long double``
``string``
``vector<bool>`` ``vector<uint8_t>``
``vector<int16_t>`` ``vector<short>``
``vector<int32_t>`` ``vector<int>``
``vector<int64_t>`` ``vector<long>``, ``vector<long long>``
``vector<double>`` ``vector<float>``
...
...
src/boost-workaround/boost/graph/graphml.hpp
View file @
d2d47234
...
...
@@ -231,7 +231,7 @@ protected:
dynamic_properties
&
m_dp
;
bool
m_ignore_directedness
;
bool
m_is_directed
;
typedef
mpl
::
vector
<
uint8_t
,
int32_t
,
int64_t
,
double
,
long
double
,
typedef
mpl
::
vector
<
uint8_t
,
int16_t
,
int32_t
,
int64_t
,
double
,
long
double
,
std
::
vector
<
uint8_t
>
,
std
::
vector
<
int32_t
>
,
std
::
vector
<
int64_t
>
,
std
::
vector
<
double
>
,
std
::
vector
<
long
double
>
,
std
::
vector
<
std
::
string
>
,
...
...
@@ -242,7 +242,7 @@ protected:
template
<
typename
MutableGraph
>
const
char
*
mutate_graph_impl
<
MutableGraph
>::
m_type_names
[]
=
{
"boolean"
,
"int"
,
"long"
,
"float"
,
"double"
,
"vector_boolean"
,
"vector_int"
,
{
"boolean"
,
"short"
,
"int"
,
"long"
,
"float"
,
"double"
,
"vector_boolean"
,
"vector_int"
,
"vector_long"
,
"vector_float"
,
"vector_double"
,
"vector_string"
,
"string"
,
"python_object"
};
...
...
@@ -325,17 +325,18 @@ write_graphml(std::ostream& out, const Graph& g, VertexIndexMap vertex_index,
" xsi:schemaLocation=
\"
http://graphml.graphdrawing.org/xmlns"
" http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd
\"
>
\n\n
"
;
typedef
mpl
::
vector
<
bool
,
uint8_t
,
int8_t
,
uint
32
_t
,
int32_t
,
uint64_t
,
int64_t
,
float
,
double
,
long
double
,
typedef
mpl
::
vector
<
bool
,
uint8_t
,
int8_t
,
uint
16
_t
,
int16_t
,
u
int32_t
,
int32_t
,
uint64_t
,
int64_t
,
float
,
double
,
long
double
,
std
::
vector
<
uint8_t
>
,
std
::
vector
<
int32_t
>
,
std
::
vector
<
int64_t
>
,
std
::
vector
<
double
>
,
std
::
vector
<
long
double
>
,
std
::
vector
<
std
::
string
>
,
std
::
vector
<
long
double
>
,
std
::
vector
<
std
::
string
>
,
std
::
string
,
python
::
object
>
value_types
;
const
char
*
type_names
[]
=
{
"boolean"
,
"boolean"
,
"boolean"
,
"int"
,
"int"
,
"long"
,
"long"
,
"float"
,
"float"
,
"double"
,
"vector_boolean"
,
"vector_int"
,
"vector_long"
,
"vector_float"
,
"vector_double"
,
"vector_string"
,
"string"
,
"python_object"
};
const
char
*
type_names
[]
=
{
"boolean"
,
"boolean"
,
"boolean"
,
"short"
,
"short"
,
"int"
,
"int"
,
"long"
,
"long"
,
"float"
,
"float"
,
"double"
,
"vector_boolean"
,
"vector_int"
,
"vector_long"
,
"vector_float"
,
"vector_double"
,
"vector_string"
,
"string"
,
"python_object"
};
std
::
map
<
std
::
string
,
std
::
string
>
graph_key_ids
;
std
::
map
<
std
::
string
,
std
::
string
>
vertex_key_ids
;
...
...
src/graph/graph_properties.cc
View file @
d2d47234
...
...
@@ -41,10 +41,10 @@ namespace graph_tool
// global property types' names
const
char
*
type_names
[]
=
{
"bool"
,
"int32_t"
,
"int64_t"
,
"double"
,
"long double"
,
"string"
,
"vector<bool>"
,
"vector<int
32
_t>"
,
"vector<int
64
_t>"
,
"vector<double>"
,
"vector<long double>"
,
"vector<string>"
,
"python::object"
};
{
"bool"
,
"int16_t"
,
"int32_t"
,
"int64_t"
,
"double"
,
"long double"
,
"string"
,
"vector<bool>"
,
"vector<int
16
_t>"
,
"vector<int
32
_t>"
,
"vector<int64_t>"
,
"vector<double>"
,
"vector<long double>"
,
"vector<string>"
,
"python::object"
};
struct
shift_vertex_property
...
...
src/graph/graph_properties.hh
View file @
d2d47234
...
...
@@ -73,8 +73,8 @@ using namespace boost;
// broken, and use a vector<uint8_t> instead!
// see: http://www.gotw.ca/publications/N1211.pdf
typedef
mpl
::
vector
<
uint8_t
,
int32_t
,
int64_t
,
double
,
long
double
,
string
,
vector
<
uint8_t
>
,
vector
<
int32_t
>
,
vector
<
int64_t
>
,
typedef
mpl
::
vector
<
uint8_t
,
int16_t
,
int32_t
,
int64_t
,
double
,
long
double
,
string
,
vector
<
uint8_t
>
,
vector
<
int16_t
>
,
vector
<
int32_t
>
,
vector
<
int64_t
>
,
vector
<
double
>
,
vector
<
long
double
>
,
vector
<
string
>
,
python
::
object
>
value_types
;
...
...
@@ -83,11 +83,11 @@ extern const char* type_names[]; // respective type names (defined in
// graph_properties.cc)
// scalar types: types contained in value_types which are scalar
typedef
mpl
::
vector
<
uint8_t
,
int32_t
,
int64_t
,
double
,
long
double
>
typedef
mpl
::
vector
<
uint8_t
,
int16_t
,
int32_t
,
int64_t
,
double
,
long
double
>
scalar_types
;
// integer_types: scalar types which are integer
typedef
mpl
::
vector
<
uint8_t
,
int32_t
,
int64_t
>
integer_types
;
typedef
mpl
::
vector
<
uint8_t
,
int16_t
,
int32_t
,
int64_t
>
integer_types
;
// floating_types: scalar types which are floating point
typedef
mpl
::
vector
<
double
,
long
double
>
floating_types
;
...
...
src/graph/numpy_bind.hh
View file @
d2d47234
...
...
@@ -46,11 +46,12 @@ using namespace boost::python;
typedef
mpl
::
map
<
mpl
::
pair
<
uint8_t
,
mpl
::
int_
<
NPY_BYTE
>
>
,
mpl
::
pair
<
uint32_t
,
mpl
::
int_
<
NPY_UINT32
>
>
,
mpl
::
pair
<
int16_t
,
mpl
::
int_
<
NPY_INT16
>
>
,
mpl
::
pair
<
int32_t
,
mpl
::
int_
<
NPY_INT32
>
>
,
mpl
::
pair
<
int64_t
,
mpl
::
int_
<
NPY_INT64
>
>
,
mpl
::
pair
<
uint64_t
,
mpl
::
int_
<
NPY_UINT64
>
>
,
mpl
::
pair
<
unsigned
long
int
,
mpl
::
int_
<
NPY_ULONG
>
>
,
mpl
::
pair
<
double
,
mpl
::
int_
<
NPY_DOUBLE
>
>
,
mpl
::
pair
<
double
,
mpl
::
int_
<
NPY_DOUBLE
>
>
,
mpl
::
pair
<
long
double
,
mpl
::
int_
<
NPY_LONGDOUBLE
>
>
>
numpy_types
;
...
...
src/graph_tool/__init__.py
View file @
d2d47234
...
...
@@ -109,7 +109,7 @@ from .decorators import _wraps, _require, _attrs, _limit_args
from
inspect
import
ismethod
__all__
=
[
"Graph"
,
"GraphView"
,
"Vertex"
,
"Edge"
,
"Vector_bool"
,
"Vector_int32_t"
,
"Vector_int64_t"
,
"Vector_double"
,
"Vector_int16_t"
,
"Vector_int32_t"
,
"Vector_int64_t"
,
"Vector_double"
,
"Vector_long_double"
,
"Vector_string"
,
"value_types"
,
"load_graph"
,
"PropertyMap"
,
"group_vector_property"
,
"ungroup_vector_property"
,
"infect_vertex_property"
,
"edge_difference"
,
"show_config"
,
...
...
@@ -164,6 +164,7 @@ def _degree(g, name):
def
_type_alias
(
type_name
):
alias
=
{
"int8_t"
:
"bool"
,
"boolean"
:
"bool"
,
"short"
:
"int16_t"
,
"int"
:
"int32_t"
,
"long"
:
"int64_t"
,
"long long"
:
"int64_t"
,
...
...
@@ -202,6 +203,8 @@ def _gt_type(obj):
t
=
type
(
obj
)
if
t
is
numpy
.
longlong
or
t
is
numpy
.
uint64
:
return
"long long"
if
issubclass
(
t
,
numpy
.
int16
):
return
"short"
if
t
is
int
or
issubclass
(
t
,
numpy
.
int
):
return
"int"
if
t
is
numpy
.
float128
:
...
...
@@ -356,12 +359,14 @@ class PropertyMap(object):
Type name Alias
======================= ======================
``bool`` ``uint8_t``
``int16_t`` ``short``
``int32_t`` ``int``
``int64_t`` ``long``, ``long long``
``double`` ``float``
``long double``
``string``
``vector<bool>`` ``vector<uint8_t>``
``vector<int16_t>`` ``short``
``vector<int32_t>`` ``vector<int>``
``vector<int64_t>`` ``vector<long>``, ``vector<long long>``
``vector<double>`` ``vector<float>``
...
...
@@ -881,9 +886,9 @@ class PropertyDict(dict):
# The main graph interface
################################################################################
from
.libgraph_tool_core
import
Vertex
,
EdgeBase
,
Vector_bool
,
Vector_int
32
_t
,
\
Vector_int64_t
,
Vector_double
,
Vector_long_double
,
Vector_string
,
\
new_vertex_property
,
new_edge_property
,
new_graph_property
from
.libgraph_tool_core
import
Vertex
,
EdgeBase
,
Vector_bool
,
Vector_int
16
_t
,
\
Vector_int32_t
,
Vector_int64_t
,
Vector_double
,
Vector_long_double
,
\
Vector_string
,
new_vertex_property
,
new_edge_property
,
new_graph_property
class
Graph
(
object
):
...
...
@@ -1795,8 +1800,8 @@ def _get_array_view(self):
def
_set_array_view
(
self
,
v
):
self
.
get_array
()[:]
=
v
vector_types
=
[
Vector_bool
,
Vector_int32_t
,
Vector_int64_t
,
Vector_double
,
Vector_long_double
]
vector_types
=
[
Vector_bool
,
Vector_int16_t
,
Vector_int32_t
,
Vector_int64_t
,
Vector_double
,
Vector_long_double
]
for
vt
in
vector_types
:
vt
.
a
=
property
(
_get_array_view
,
_set_array_view
,
doc
=
r
"""Shortcut to the `get_array` method as an attribute."""
)
...
...
Write
Preview
Supports
Markdown
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