> For the complete documentation index, see [llms.txt](https://ksmcclay.gitbook.io/no-code-computer-science/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ksmcclay.gitbook.io/no-code-computer-science/data-structures/graph-network.md).

# Network (Graph)

## What is a Network (Graph) :fireworks:&#x20;

A **Network** is a collection of connected nodes. nodes = elements

![Courtesy of NASA taken from ISS](/files/-MLyjXnx0ADlolyW1KNA)

## Earth :earth\_americas: :earth\_africa: :earth\_asia:&#x20;

Viewing earth from the international space station, there is clusters of light in a sea of darkness. These pockets of light are highly connected **Networks** of people and things people make.  &#x20;

## Social Network :globe\_with\_meridians:&#x20;

A **Social Network** is groups of people connected together.&#x20;

![Each line is equal to a friendship](/files/-MMC96K9GVhtpkP_w_-a)

Kyle's Facebook Friend Profile: :globe\_with\_meridians:

* Family Network:
  * :heart:Wife, Kids, parents, grandparents, cousins, aunts, uncles, inlaws:heart:
* Friends Network:
  * childhood friends:baby\_bottle:, work friends:woman\_construction\_worker:, hobbie friends:basketball::video\_game:
* Dank Meme & Programming Network: :100:&#x20;
  * :stuck\_out\_tongue\_winking\_eye:weirdos:zany\_face:more weirdos:lying\_face:&#x20;

I'm personally connected to all these people above in a **Network**. All of the people im connected to are also connected to their own people. and all of those people are... etc, etc, etc...&#x20;

## I Need a Map, A Map of the Internet! :brain:

**Networks** are used to represent more complicated relationships and normally used when other data structures simply will not work.&#x20;

![Partial map of the Internet from opte.org](/files/-MLz92PPBxK7qe78RXYp)

## Types of Networks :wind\_blowing\_face: :cloud\_tornado:&#x20;

**Directed Networks**: Connections between nodes flow in a specific direction&#x20;

* Water always flows in one direction from a higher point to a lower point&#x20;
  * :park: Water Tower -> Homes -> Sewer :park:&#x20;
* Twitters following/follower system
  * I follow the @PresidentOfTheUnitedStates :person\_walking:&#x20;
  * The President Of The United States does **Not** follow me :no\_entry\_sign:&#x20;

**Undirected Networks**: Connections between nodes flow in both directions

* Facebooks friend system
  * I send a friend request to uncle Jim Bob and he accepts :men\_with\_bunny\_ears\_partying:&#x20;

## Linked List vs Tree vs Network:apple: :evergreen\_tree: :earth\_americas:&#x20;

**Linked List** and **Trees** can be represented as simple **Networks**. The following example explains the differences between the 3 as different types of networks.

**Example:**

* 7 Nodes = A, B, C, D, E, F, G :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star: :eight\_pointed\_black\_star:&#x20;

**Linked Lists:** a simple directed network where each node flows to the next node. :point\_right:

* ```
  (start) A -> B -> C -> D -> E -> F -> G -> END
  ```

**Trees:** are a directed network where the starting node flows down to multiple nodes :point\_left::point\_right:&#x20;

* ```
             (start)
                A 
                '
        -------------------
       '                   '
       B                   C
       '                   '
   -----------         -----------
  '           '       '           '
  D           E       F           G
  ```

**Networks:** can be used to diagram highly connected systems:point\_left::point\_right::point\_up\_2::point\_down::call\_me:

* ```
  - = 2-way connection
  ' = 2-way connection
  x = 4-way connection
  No starting point 
  No ending point
  ```
* ```
  A  -  B  -  C
  '  x  '  x  '
  D  -  E  -  F
  '  x  '  x  '
  ----- G -----
  ```

The key takeaway is all systems have the same number of **Nodes** but a different number of **Connections.** The **Connections** are what make the data structure a linked list, tree or networ&#x6B;**.**


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ksmcclay.gitbook.io/no-code-computer-science/data-structures/graph-network.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
