<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/neural-structured-learning/blob/v1.4.0/neural_structured_learning/tools/graph_utils.py#L52-L75) |

Adds an edge to a given graph.

#### View aliases


**Main aliases**

[`nsl.tools.graph_utils.add_edge`](https://www.tensorflow.org/neural_structured_learning/api_docs/python/nsl/tools/add_edge)

<br />

    nsl.tools.add_edge(
        graph, edge
    )

If an edge between the two nodes already exists, the one with the largest
weight is retained.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `graph` | A `dict`: source_id -\> (target_id -\> weight) to be augmented. |
| `edge` | A `list` (or `tuple`) of the form `[source, target, weight]`, where `source` and `target` are strings, and `weight` is a numeric value of type `string` or `float`. The 'weight' component is optional; if not supplied, it defaults to 1.0. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `True` if and only if a new edge was added to `graph`. ||

<br />