<commit_before># Graph

> The developers' draft

## Dependency loading

We say vertex X is ready, if
- `X.ready === true`, or
- has no dependencies, or
- each dependency Y of X
  - is ready, or
  - there is a path directed from Y to X, which forms a [strongly connected graph](http://en.wikipedia.org/wiki/Strongly_connected_component), and each vertex on the path is loaded.

If X is a vertex of a strongly connected graph, and X is ready, then all vertices of the graph are ready.

Suppose there is a dependency graph

```
   A ─────> B(ready)
   |
   v
   C <──────┬──────> E(ready)
   |        |
   └──────> D ─────> F ─────> G
            ^                 |
            |                 |
            └─────────────────┘
```

We want to check if A is ready. So,

`A.ready <==> C.ready`

We are not sure if C is ready, and we found C has a depe
ndency D, so

`C.read <==> D.ready`

D has 3 dependencies,
- E is ready
- C: there is a path C -> D
- F: there is a path F -> D

So, D is ready, which indicates A is ready.


## Shrinkwrap

using object `refs` as optimization:

### graph

```js
// modules
[
  // 0
  [
    "F@2.1.0"
  ],
  // 1
  [
    "E@1.9.0"
  ],
  // 2
  [
    "Y@1.1.0",
    {
      "X@~1.1.0": 3
    }
  ],
  // 3
  [
    "X@1.1.0", 
    {
      "Y@~1.1.0": 2
    }
  ],
  // 4
  [
    "A@1.2.0", 
    {
      "D@^4.0.0": 6
      "F@^2.0.0": 0
    }
  },
  // 5
  [
    "B@5.0.0",
    {
      "D@^4.0.0": 7
      "F@^2.0.0": 0
    }
  ],
  // 6
  [
    "D@4.1.0",
    {
      "E@^1.0.0": 8
    }
  ],
  // 7
  [
    "D@4.1.0",
    {
      "E@^1.0.0": 1
    }
  ],
  [
    "E@1.1.0"
  ]
]
```
<commit_msg>Update graph.md<commit_after># Graph

> The developers' draft

## Dependency loading

We say vertex X is ready, if
- `X.ready === true`, or
- has no dependencies, or
- each dependency Y of X
  - is ready, or
  - there is a path directed from Y to X, which forms a [strongly connected graph](http://en.wikipedia.org/wiki/Strongly_connected_component), and each vertex on the path is loaded.

If X is a vertex of a strongly connected graph, and X is ready, then all vertices of the graph are ready.

Suppose there is a dependency graph

```
   A ─────> B(ready)
   |
   v
   C <──────┬──────> E(ready)
   |        |
   └──────> D ─────> F ─────> G
            ^                 |
            |                 |
            └─────────────────┘
```

We want to check if A is ready. So,

`A.ready <==> C.ready`

We are not sure if C is ready, and we found C has a depe
ndency D, so

`C.read <==> D.ready`

D has 3 dependencies,
- E is ready
- C: there is a path C -> D
- F: there is a path F -> D

So, D is ready, which indicates A is ready.


## Shrinkwrap

using object `refs` as optimization:

### graph

```js
// modules
{
  0: [
    "F@2.1.0"
  ],
  1: [
    "E@1.9.0"
  ],
  2: [
    "Y@1.1.0",
    {
      "X@~1.1.0": 3
    }
  ],
  3: [
    "X@1.1.0", 
    {
      "Y@~1.1.0": 2
    }
  ],
  4: [
    "A@1.2.0", 
    {
      "D@^4.0.0": 6
      "F@^2.0.0": 0
    }
  ],
  5: [
    "B@5.0.0",
    {
      "D@^4.0.0": 7
      "F@^2.0.0": 0
    }
  ],
  6: [
    "D@4.1.0",
    {
      "E@^1.0.0": 8
    }
  ],
  7: [
    "D@4.1.0",
    {
      "E@^1.0.0": 1
    }
  ],
  8: [
    "E@1.1.0"
  ],

  _: [
    "_",
    {
      "A": 4,
      "B@5.0.0": 5,
      "B^5.0.0"
    }
  ]
}
```

{'fraction_non_alphanumeric': 0.2042232277526395, 'fraction_numerical': 0.043740573152337855, 'mean_word_length': 1.5546995377503852, 'pattern_counts': {'":': 18, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1141175', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1433, 'n_words': 401}