{"id":18792361,"url":"https://github.com/kplanisphere/graph-adjacency-matrix","last_synced_at":"2025-12-28T09:30:14.472Z","repository":{"id":241965948,"uuid":"808331280","full_name":"KPlanisphere/graph-adjacency-matrix","owner":"KPlanisphere","description":"Proyecto 4 - Estructuras de Datos","archived":false,"fork":false,"pushed_at":"2024-05-30T21:05:25.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T15:26:05.023Z","etag":null,"topics":["adjacency-matrix","algorithm-implementation","cpp","data-structures","graph-operations","graph-theory","matrix-multiplication","menu-driven-interface"],"latest_commit_sha":null,"homepage":"https://linktr.ee/planisphere.kgz","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KPlanisphere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T21:04:52.000Z","updated_at":"2024-05-30T21:31:37.000Z","dependencies_parsed_at":"2024-05-30T23:43:19.147Z","dependency_job_id":"95bea904-321c-4fff-913f-7a5a217769ab","html_url":"https://github.com/KPlanisphere/graph-adjacency-matrix","commit_stats":null,"previous_names":["kplanisphere/graph-adjacency-matrix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fgraph-adjacency-matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fgraph-adjacency-matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fgraph-adjacency-matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPlanisphere%2Fgraph-adjacency-matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KPlanisphere","download_url":"https://codeload.github.com/KPlanisphere/graph-adjacency-matrix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718371,"owners_count":19685725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adjacency-matrix","algorithm-implementation","cpp","data-structures","graph-operations","graph-theory","matrix-multiplication","menu-driven-interface"],"created_at":"2024-11-07T21:19:37.880Z","updated_at":"2025-12-28T09:30:14.401Z","avatar_url":"https://github.com/KPlanisphere.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graph Adjacency Matrix Operations\n\nThis project implements operations on a graph represented by an adjacency matrix in C++. The program allows users to input graph data, perform matrix multiplications to determine paths of length 2 and 3, verify adjacency, and print the adjacency matrix. It includes a menu-driven interface for easy user interaction.\n\n## Features\n\n- **Input Graph Data**: Allows the user to input the adjacency matrix of a graph.\n- **Print Adjacency Matrix**: Displays the current adjacency matrix.\n- **Verify Adjacency**: Checks if two nodes are adjacent.\n- **Matrix Multiplication for Paths**: Calculates and displays the matrix for paths of length 2 (M^2) and length 3 (M^3).\n- **Menu Interface**: Provides a user-friendly menu to perform the above operations.\n\n## Usage\n\nCompile the program using a C++ compiler and run the executable. The user will be prompted to enter the cardinality of the graph and then interact with a menu to perform various operations.\n\n### Example Commands\n\n1. **Input New Graph**: Enter the adjacency matrix for a new graph.\n2. **Print Current Adjacency Matrix**: Displays the current adjacency matrix.\n3. **Verify Adjacency**: Checks if two specified nodes are adjacent.\n4. **Print M^2**: Calculates and prints the matrix representing paths of length 2.\n5. **Print M^3**: Calculates and prints the matrix representing paths of length 3.\n6. **Exit**: Terminates the program.\n\n## Code Snippets\n\n### Reserve Memory for Matrix\n```cpp\nint** reservarMemoria(size_t card) {\n    int** matriz = new int* [card];\n    for (size_t f(0); f \u003c card; ++f) {\n        matriz[f] = new int[card];\n    }\n    return matriz;\n}\n```\n\n### Matrix Multiplication\n\n```cpp\nvoid multMatriz(int card, int** A, int** B, int p) {\n    int** C = reservarMemoria(card);\n    for (int i = 0; i \u003c card; i++) {\n        for (int j = 0; j \u003c card; j++) {\n            C[i][j] = 0;\n            for (int k = 0; k \u003c card; k++) {\n                C[i][j] = C[i][j] + A[i][k] * B[k][j];\n            }\n        }\n    }\n    if (p == 0) {\n        multMatriz(card, C, A, 1);\n    } else {\n        impMatriz(card, C);\n    }\n}\n```\n\n### Menu Interface\n\n```cpp\nvoid menu() {\n    int op = 0, card = 0;\ncardinalidad:\n    system(\"cls\");\n    do {\n        system(\"cls\");\n        cout \u003c\u003c \"\\n/////// CARDINALIDAD DEL GRAFO: \";\n        cin \u003e\u003e card;\n        if (card \u003c 2) {\n            cout \u003c\u003c \"\\n[!] ERROR: INGRESA UN VALOR VALIDO [!]\";\n            pause = cin.get(); //PAUSA\n            pause = cin.get(); //PAUSA\n        }\n    } while (card \u003c 2);\n    int** matriz = reservarMemoria(card);\n    entrada(card, matriz);\n    do {\n        system(\"cls\");\n        cout \u003c\u003c \"\\n/////// PRACTICA: MATRIZ DE ADYACENCIA/GRAFOS\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\nSELECCIONE UNA OPCION:\\n\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[1] INGRESAR UN NUEVO GRAFO\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[2] IMPRIMIR MATRIZ DE ADYACENCIA ACTUAL\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[3] CORROBORAR ADYACENCIA\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[4] IMPRIMIR M^2\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[5] IMPRIMIR M^3\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\t[6] SALIR\" \u003c\u003c endl;\n        cout \u003c\u003c \"\\n\u003e\u003e \";\n        cin \u003e\u003e op;\n        pause = cin.get(); //PAUSA\n        switch (op) {\n        case 1:\n            goto cardinalidad;\n            break;\n        case 2:\n            cout \u003c\u003c \"\\n/////// MATRIZ DE ADYACENCIA ACTUAL\\n\" \u003c\u003c endl;\n            impMatriz(card, matriz);\n            pause = cin.get(); //PAUSA\n            break;\n        case 3:\n            corroborar(card, matriz);\n            break;\n        case 4:\n            cout \u003c\u003c \"\\n/////// M^2\\n\" \u003c\u003c endl;\n            multMatriz(card, matriz, matriz, 1);\n            break;\n        case 5:\n            cout \u003c\u003c \"\\n/////// M^3\\n\" \u003c\u003c endl;\n            multMatriz(card, matriz, matriz, 0);\n            break;\n        default:\n            cout \u003c\u003c \"\\n\\tIngresa una opcion valida\" \u003c\u003c endl;\n            pause = cin.get(); //PAUSA\n            break;\n        }\n    } while (op != 6);\n}\n```\n\n## How to Run\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/KPlanisphere/graph-adjacency-matrix.git\n    ```\n2. Navigate to the project directory:\n    ```bash\n    cd graph-adjacency-matrix\n    ```\n3. Compile the code:\n    ```bash\n    g++ GrafoMatriz.cpp -o graph_matrix\n    ```\n4. Run the executable:\n    ```bash\n    ./graph_matrix\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkplanisphere%2Fgraph-adjacency-matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkplanisphere%2Fgraph-adjacency-matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkplanisphere%2Fgraph-adjacency-matrix/lists"}