# GraphSourceBase

Telerik Diagramming Framework provides a list of **ViewModels** defined in the **Telerik.Windows.Controls.Diagrams.Extensions.dll**.

This article describes the **GraphSourceBase\<TNode, TLink>** class defined in the Diagramming Extensions.

## Overview

The **GraphSourceBase\<TNode, TLink>** class is designed to serve as a base **ViewModel** that represents the collections of nodes and shapes in a data-bound **RadDiagram**. In a **RadDiagram** you always need to consider the fact that it consists of different types of items - **RadDiagramConnections** and **RadDiagramShapes**. This is why the **RadDiagram GraphSource** should be set to an instance of a class that implements the[IGraphSource](http://www.telerik.com/help/wpf/t_telerik_windows_diagrams_core_igraphsource_1.html) interface. This interface defines two collections - one with Items and one with Links.

The **GraphSourceBase** class implements the **IGraphSource** interface and it also provides methods that work with the **Items** and **Links** collections.

> Please keep in mind that in the **GraphSourceBase\<TNode, TLink>** implementation, **TLink** should derive from the [ILink<T>](http://www.telerik.com/help/wpf/t_telerik_windows_diagrams_core_ilink_1.html) interface.

GraphSourceBase\<TNode, TLink> Inheritance Model
![raddiagram-data-graphsource](https://www.telerik.com/products/wpf/documentation/assets/2966e356b64ce52063c4ac5caf7c15e6/raddiagram-data-graphsource.png)

**GraphSourceBase** has one constructor - GraphSourceBase() that initializes a new instance of the class.

## Properties

**GraphSourceBase** exposes the following properties:

| Name          | Description                                               |
| ------------- | --------------------------------------------------------- |
| InternalItems | Gets the internal ObservableCollection of business nodes. |
| InternalLinks | Gets the internal ObservableCollection of business links. |
| Items         | Gets an IEnumerable collection of business nodes.         |
| Links         | Gets an IEnumerable collection of business links.         |

## Methods

**GraphSourceBase** exposes the following virtual methods:

| Name              | Description                                                                                                                                      |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| AddNode(TNode)    | Adds a specified business node to the InternalItems collection.                                                                                  |
| AddLink(TLink)    | Adds a specified business link to the InternalLinks collection.                                                                                  |
| RemoveLink(TLink) | Removes a specified business link from the InternalLinks collection and returns a boolean value indicating whether the operation was successful. |
| RemoveItem(TNode) | Removes a specified business node from the InternalItems collection and returns a boolean value indicating whether the operation was successful. |
| Clear             | Removes all nodes and links from the InternalItems and InternalLinks collections.                                                                |

> Please note that in your solution it is best to create a custom class deriving from **GraphSourceBase**. Once you do so, you will be able to override all of the above virtual methods and describe a custom **RadDiagram GraphSource** implementation.

## See Also

* [ItemViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-itemviewmodels)
* [NodeViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-nodeviewmodel)
* [LinkViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-linkviewmodel)
* [ContainerNodeViewModelBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-containernodeviewmodel)
* [HierarchicalNodeViewModel](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-hierarchicalnodeviewmodel)
* [ObservableGraphSourceBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-observablegraphsource)
* [SerializableGraphSourceBase](https://www.telerik.com/products/wpf/documentation/controls/raddiagram/diagramextensions-viewmodels/data-serializablegraphsource)
