# Adjacency matrix

## What is adjacency matrix?

Adjacency matrix is the type of graph visualization in form of matrix; crossing of columns and rows determines the edges. Using adjacency matrix you can determine the edges' weight and orientation. Every matrix's row and column correspond to edges; the number of the row corresponds to the vertex, where an edge starts; the number of the column corresponds to the vertex where an edge finishes.

## Examples of adjacency matrices

Graph consisting of 3 connected vertices | Graph with oriented edge | Graph consistiong of 4 vertices without edges |
---|---|---|

0, 1, 1, 1, 0, 1, 1, 1, 0, |
0, 1, 0, 0, |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |

Ссылка на граф | Ссылка на граф | Ссылка на граф |

## Adjacency matrix in Graph Online

Graph Online allows you to create Создать граф по матрице смежности.

Moreover, users can edit the existing adjacency matrix. In order to do that you have to choose Graph in the menu bar and then Adjacency matrix.

In order to use adjacency matrix you have to enter it in the right form.

## How to enter adjacency matrix

Entering an adjacency matrix you have to take into account the following principles:

- A matrix should be square; the number of rows should be equal to the number of columns.
- Every new row should be entered from the new line.
- Every figure is followed by comma (,)
- The weight of the edge should be a positive number. Value "0" means the edge does not exist.

Let's look through the major mistakes which the user may face while entering an adjacency matrix

### Major mistakes which happen while entering adjacency matrix

The wrong matrix | The cause of the mistake | The correct matrix |
---|---|---|

5,5,5,5,5 5,5,5,5,5 5,5,5,5,5 | The matrix is not square; the number of rows is 3 and the number of columns is 5 |
5,5,5,5,5 5,5,5,5,5 5,5,5,5,5 5,5,5,5,5 5,5,5,5,5 |

0,1,1,1,0,1,0,0,0 1,0,1,0,0,1,1,1,0 1,1,0,1,1,0,1,0,0 1,0,1,0,1,1,1,1,0 0,0,1,1,0,1,0,0,0 1,1,0,1,1,0,1,1,1 0,1,1,1,0,1,0,0,1 0,0,0,0,0,1,1,1,0 | The matrix is not square; the number of rows is 8 and the number of columns is 9 |
0,1,1,1,0,1,0,0,0 1,0,1,0,0,1,1,1,0 1,1,0,1,1,0,1,0,0 1,0,1,0,1,1,1,1,0 0,0,1,1,0,1,0,0,0 1,1,0,1,1,0,1,1,1 0,1,1,1,0,1,0,0,1 0,0,0,0,0,1,1,1,0 0,0,0,0,0,0,0,0,0 |

1, 0, 0 1, 2, 0 -2, 1, 0 0, -2, 0 1, 3, 0 | The matrix is not square, it also contains negative values |
1, 0, 0 1, 2, 0 2, 1, 0 |

1 2, 1 3, 1 4, 4 5, 5 2, 6 3, | Dependence between the vertices was entered instead of an adjacency matrix. You have to enter an adjacency matrix for that graph. |
0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, |

∞,10,9,10 10,∞,∞,∞ ∞,5,∞.8 10,∞,∞,∞ | Instead of symbol "∞" use "0". |
0,10,9,10 10,0,0,0 0,5,0.8 10,0,0,0 |

-, 8, -, 1, -, -, -, -, 4, 7, 2, -, -, -, -, -, 4, 2, -, -, 9, -, 7, -, -, -, -, -, -, 6, inf , -, -, -, -, -, | Instead of symbol "-" or 'inf" use 0". |
0, 8, 0, 1, 0, 0, 0, 0, 4, 7, 2, 0, 0, 0, 0, 0, 4, 2, 0, 0, 9, 0, 7, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, |