# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `Graph`::`setVertexWeights`

Assigns vertex weights to vertices.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```Graph::setVertexWeights(`G`, `Vertex`, `VertexWeights`)
```

## Description

`Graph::setVertexWeights(G, Vertex, VertexWeights)` returns a graph where the vertices in `Vertex` have the vertex weights `VertexWeights`.

### Note

The substitute `None` can be used when a specified edge should not get the assigned weights.

## Examples

### Example 1

How to set vertex weights with a list:

```G1 := Graph::createCircleGraph(3): Graph::getVertexWeights(G1)```

`FAIL` was returned, because no vertex weights were defined.

```Graph::getVertices(G1); G1 := Graph::setVertexWeights(G1, [1, 3], [5, 1/2]): Graph::getVertexWeights(G1)```

The first output shows all vertices and the second the assigned vertex weights.

### Example 2

How to set vertex weights with a table:

```G1 := Graph::createCompleteGraph(3): Graph::getVertexWeights(G1)```

`FAIL` was returned, because no vertex weights were defined.

```G2 := Graph::createCompleteGraph(3): tbl := table(1 = 15, 3 = 20): G2 := Graph::setVertexWeights(G2, [1, 3], tbl): Graph::getVertexWeights(G2)```

## Parameters

 `G` A graph `Vertex` A list of one or more vertices `VertexWeights` A list of one or more numbers, or a table consisting of the vertices with their weights.

## Return Values

New graph with the corrected vertex weights.