2.6. Copying vectors

2.6.1. igraph_vector_copy_to — Copies the contents of a vector to a C array.
2.6.2. igraph_vector_update — Update a vector from another one.
2.6.3. igraph_vector_append — Append a vector to another one.
2.6.4. igraph_vector_swap — Swap elements of two vectors.

2.6.1. igraph_vector_copy_to — Copies the contents of a vector to a C array.

void igraph_vector_copy_to(const igraph_vector_t *v, igraph_real_t *to);

The C array should have sufficient length.

Arguments: 

v:

The vector object.

to:

The C array.

Time complexity: O(n), n is the size of the vector.

2.6.2. igraph_vector_update — Update a vector from another one.

int igraph_vector_update(igraph_vector_t *to, 
				   const igraph_vector_t *from);

After this operation the contents of to will be exactly the same from. to will be resized if it was originally shorter or longer than from.

Arguments: 

to:

The vector to update.

from:

The vector to update from.

Returns: 

Error code.

Time complexity: O(n), the number of elements in from.

2.6.3. igraph_vector_append — Append a vector to another one.

int igraph_vector_append(igraph_vector_t *to, 
				   const igraph_vector_t *from);

The target vector will be resized (except from is empty).

Arguments: 

to:

The vector to append to.

from:

The vector to append, it is kept unchanged.

Returns: 

Error code.

Time complexity: O(n), the number of elements in the new vector.

2.6.4. igraph_vector_swap — Swap elements of two vectors.

int igraph_vector_swap(igraph_vector_t *v1, igraph_vector_t *v2);

The two vectors must have the same length, otherwise an error happens.

Arguments: 

v1:

The first vector.

v2:

The second vector.

Returns: 

Error code.

Time complexity: O(n), the length of the vectors.