{"record":{"id":"7d06880c1bc68bb8","repo":"krahets/hello-algo","slug":"error-7d0688","errorCode":null,"errorMessage":"グラフの頂点数が最大値に達しました\n","messagePattern":"グラフの頂点数が最大値に達しました\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ja/codes/c/chapter_graph/graph_adjacency_matrix.c","lineNumber":39,"sourceCode":"    GraphAdjMat *graph = (GraphAdjMat *)malloc(sizeof(GraphAdjMat));\n    graph->size = 0;\n    for (int i = 0; i < MAX_SIZE; i++) {\n        for (int j = 0; j < MAX_SIZE; j++) {\n            graph->adjMat[i][j] = 0;\n        }\n    }\n    return graph;\n}\n\n/* デストラクタ */\nvoid delGraphAdjMat(GraphAdjMat *graph) {\n    free(graph);\n}\n\n/* 頂点を追加 */\nvoid addVertex(GraphAdjMat *graph, int val) {\n    if (graph->size == MAX_SIZE) {\n        fprintf(stderr, \"グラフの頂点数が最大値に達しました\\n\");\n        return;\n    }\n    // n 番目の頂点を追加し、n 行目と n 列目を 0 にする\n    int n = graph->size;\n    graph->vertices[n] = val;\n    for (int i = 0; i <= n; i++) {\n        graph->adjMat[n][i] = graph->adjMat[i][n] = 0;\n    }\n    graph->size++;\n}\n\n/* 頂点を削除 */\nvoid removeVertex(GraphAdjMat *graph, int index) {\n    if (index < 0 || index >= graph->size) {\n        fprintf(stderr, \"頂点インデックスが範囲外です\\n\");\n        return;\n    }\n    // 頂点リストから index の頂点を削除する","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/krahets/hello-algo/blob/69932aed1891a7b7f6a0de88cd116d3fe13e7032/ja/codes/c/chapter_graph/graph_adjacency_matrix.c#L21-L57","documentation":"Japanese localization of the addVertex capacity check (see error 600). The adjacency-matrix graph holds at most MAX_SIZE (100) vertices in fixed compile-time-sized arrays; on the 101st insertion addVertex writes this message to stderr and returns void without inserting.","triggerScenarios":"addVertex(graph, val) called when graph->size == 100. Any insertion beyond the fixed cap triggers it.","commonSituations":"Loading more than 100 nodes into the teaching graph; benchmarks exceeding the illustrative limit; assuming dynamic growth when the structure is fixed-size.","solutions":["Limit input to 100 vertices, pruning or partitioning beforehand.","Increase #define MAX_SIZE and recompile (memory scales O(MAX_SIZE^2)).","Use the adjacency-list implementation for larger graphs."],"exampleFix":"// before\nfor (int i = 0; i < 1000; i++) addVertex(graph, i);\n\n// after\nfor (int i = 0; i < 1000 && graph->size < MAX_SIZE; i++) addVertex(graph, i);","handlingStrategy":"validation","validationCode":"static inline int graphCanAddVertex(const GraphAdjMat *g) {\n    return g != NULL && g->size < MAX_SIZE;\n}\n\nif (graphCanAddVertex(graph)) addVertex(graph, val);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat MAX_SIZE (100) as a hard contract; assert before each addVertex in debug builds.","Pick the adjacency-list implementation up front for graphs that may exceed 100 nodes.","Wrap addVertex in a helper returning a status code so failures are detectable beyond stderr."],"tags":["graph","capacity","adjacency-matrix","fixed-size","c","i18n-ja"],"backgroundTag":null,"analyzedSha":"69932aed1891a7b7f6a0de88cd116d3fe13e7032","analyzedAt":"2026-08-13T23:02:37.581Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}