# checkGraph: Checks if the graph contains at least one tree or one... In optrees: Optimal Trees in Weighted Graphs

## Description

The `checkGraph` function checks if it is possible to find at least one tree (or arborescence, if it is the case) in the graph. It only happens when the graph is connected and it is posible to find a walk from the source to any other node.

## Usage

 `1` ```checkGraph(nodes, arcs, source.node = 1, directed = TRUE) ```

## Arguments

 `nodes` vector containing the nodes of the graph, identified by a number that goes from 1 to the order of the graph. `arcs` matrix with the list of arcs of the graph. Each row represents one arc. The first two columns contain the two endpoints of each arc and the third column contains their weights. `source.node` number pointing the source node of the graph. `directed` logical value indicating whether the graph is directed (`TRUE`) or not (`FALSE`).

## Value

`checkGraph` returns the value `TRUE` if the graph meets the requirements and `FALSE` otherwise. If the graph is not acceptable this functions also prints the reason.

## Examples

 ```1 2 3 4 5 6``` ```# Graph nodes <- 1:4 arcs <- matrix(c(1,2,2, 1,3,15, 2,3,1, 2,4,9, 3,4,1), byrow = TRUE, ncol = 3) # Check graph checkGraph(nodes, arcs) ```

### Example output

```Loading required package: igraph

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

decompose, spectrum

The following object is masked from 'package:base':

union

[1] TRUE
```

optrees documentation built on May 29, 2017, 9:40 p.m.