diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4e616a5f6b984ed8007af2ee595c47ccb850b117..6e896b6390085cbe7ade7c9c6b9dde61d2551616 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -37,6 +37,7 @@ env:
   SPARSE_CHECKOUT: |-
     .github/actions/
     data/
+    patches/
     tools/
     package.json
     pnpm-lock.yaml
diff --git a/lib/modules/manager/nuget/package-tree.ts b/lib/modules/manager/nuget/package-tree.ts
index 56b3f874ff647021fbcf72b5c233c2ee0bf9dc2a..fd4595e31d453e1d0dec4b9a69633509fc24c20d 100644
--- a/lib/modules/manager/nuget/package-tree.ts
+++ b/lib/modules/manager/nuget/package-tree.ts
@@ -1,5 +1,5 @@
 import is from '@sindresorhus/is';
-import { Graph } from 'graph-data-structure';
+import { Graph, hasCycle } from 'graph-data-structure';
 import upath from 'upath';
 import { logger } from '../../../logger';
 import { minimatchFilter } from '../../../util/minimatch';
@@ -18,7 +18,7 @@ export async function getDependentPackageFiles(
   isCentralManagement = false,
 ): Promise<ProjectFile[]> {
   const packageFiles = await getAllPackageFiles();
-  const graph: ReturnType<typeof Graph> = Graph();
+  const graph = new Graph();
 
   if (isCentralManagement) {
     graph.addNode(packageFileName);
@@ -62,7 +62,7 @@ export async function getDependentPackageFiles(
       graph.addEdge(ref, f);
     }
 
-    if (graph.hasCycle()) {
+    if (hasCycle(graph)) {
       throw new Error('Circular reference detected in NuGet package files');
     }
   }
@@ -84,12 +84,12 @@ export async function getDependentPackageFiles(
  */
 function recursivelyGetDependentPackageFiles(
   packageFileName: string,
-  graph: ReturnType<typeof Graph>,
+  graph: Graph,
   deps: Map<string, boolean>,
 ): void {
   const dependents = graph.adjacent(packageFileName);
 
-  if (dependents.length === 0) {
+  if (!dependents || dependents.size === 0) {
     deps.set(packageFileName, true);
     return;
   }
diff --git a/lib/modules/manager/pip-compile/utils.ts b/lib/modules/manager/pip-compile/utils.ts
index 50fcdde6585feb99ea16f11594cfcd248bc89603..8ae1d5126903d4939cced3bf0bd21e3f5e6fedb0 100644
--- a/lib/modules/manager/pip-compile/utils.ts
+++ b/lib/modules/manager/pip-compile/utils.ts
@@ -1,4 +1,4 @@
-import { Graph } from 'graph-data-structure';
+import { Graph, topologicalSort } from 'graph-data-structure';
 import upath from 'upath';
 import { logger } from '../../../logger';
 import type { PackageFile } from '../types';
@@ -9,11 +9,11 @@ export function sortPackageFiles(
   packageFiles: Map<string, PackageFile>,
 ): PackageFile[] {
   const result: PackageFile[] = [];
-  const graph: ReturnType<typeof Graph> = Graph();
+  const graph = new Graph();
   depsBetweenFiles.forEach(({ sourceFile, outputFile }) => {
     graph.addEdge(sourceFile, outputFile);
   });
-  const sorted = graph.topologicalSort();
+  const sorted = topologicalSort(graph);
   for (const file of sorted) {
     if (packageFiles.has(file)) {
       const packageFile = packageFiles.get(file)!;
diff --git a/package.json b/package.json
index 66cf98e64d47ffcf6cfb59945d3d77f233984d6c..392fcac80a322abdddca87707e3de096902e657b 100644
--- a/package.json
+++ b/package.json
@@ -205,7 +205,7 @@
     "good-enough-parser": "1.1.23",
     "google-auth-library": "9.14.2",
     "got": "11.8.6",
-    "graph-data-structure": "3.5.0",
+    "graph-data-structure": "4.2.0",
     "handlebars": "4.7.8",
     "ignore": "6.0.2",
     "ini": "5.0.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6b22f2a3315b2b816137c744e41bcb0df21ab368..ecc090d1fa68b81e4e1e08bb16237d2a2c42b4d1 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -198,8 +198,8 @@ importers:
         specifier: 11.8.6
         version: 11.8.6
       graph-data-structure:
-        specifier: 3.5.0
-        version: 3.5.0
+        specifier: 4.2.0
+        version: 4.2.0
       handlebars:
         specifier: 4.7.8
         version: 4.7.8
@@ -1187,7 +1187,6 @@ packages:
 
   '@ls-lint/ls-lint@2.2.3':
     resolution: {integrity: sha512-ekM12jNm/7O2I/hsRv9HvYkRdfrHpiV1epVuI2NP+eTIcEgdIdKkKCs9KgQydu/8R5YXTov9aHdOgplmCHLupw==}
-    cpu: [x64, arm64, s390x]
     os: [darwin, linux, win32]
     hasBin: true
 
@@ -3617,8 +3616,8 @@ packages:
   graceful-fs@4.2.11:
     resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
 
-  graph-data-structure@3.5.0:
-    resolution: {integrity: sha512-AAgjRtBZC1acIExgK2otv2LDdcYeZdQFKiEStXRDTyaVs6sUUaGUif05pCczTqAU4ny82NQtM1p5PK7AQEYgRA==}
+  graph-data-structure@4.2.0:
+    resolution: {integrity: sha512-DFGyFROTYJAXwLjBPvj6LYihF2zIUDKt6Rzgo18E+FFKtHm7dJnE/bMHVp6fji5IchykUg3ctS9gwS0L5azwDw==}
 
   grapheme-splitter@1.0.4:
     resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==}
@@ -10445,7 +10444,7 @@ snapshots:
 
   graceful-fs@4.2.11: {}
 
-  graph-data-structure@3.5.0: {}
+  graph-data-structure@4.2.0: {}
 
   grapheme-splitter@1.0.4: {}