"delete node in graph in c" Code Answer's

You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "delete node in graph in c" answered properly. Developers are finding an appropriate answer about delete node in graph in c related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like delete node in graph in c. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on delete node in graph in c. 

delete node in graph in c

By Strange SkimmerStrange Skimmer on Dec 28, 2020
#include<stdio.h>
#define max 20
int adj[ max ][ max ];
int n;
main()
{
    int choice;
    int node, origin, destin;
    create_graph();
    while ( 1 )
        {
            printf( "1.Insert a node\n" );
            printf( "2.Insert an edge\n" );
            printf( "3.Delete a node\n" );
            printf( "4.Delete an edge\n" );
            printf( "5.Dispaly\n" );
            printf( "6.Exit\n" );
            printf( "Enter your choice : " );
            scanf( "%d", &choice );
            switch ( choice )
                {
                case 1:
                    insert_node();
                    break;
                case 2:
                    printf( "Enter an edge to be inserted : " );
                    fflush( stdin );
                    scanf( "%d %d", &origin, &destin );
                    insert_edge( origin, destin );
                    break;
                case 3:
                    printf( "Enter a node to be deleted : " );
                    fflush( stdin );
                    scanf( "%d", &node );
                    delete_node( node );
                    break;
                case 4:
                    printf( "Enter an edge to be deleted : " );
                    fflush( stdin );
                    scanf( "%d %d", &origin, &destin );
                    del_edge( origin, destin );
                    break;
                case 5:
                    display();
                    break;
                case 6:
                    exit();
                default:
                    printf( "Wrong choice\n" );
                    break;
                } /*End of switch*/
        } /*End of while*/
} /*End of main()*/
create_graph()
{
    int i, max_edges, origin, destin;
    printf( "Enter number of nodes : " );
    scanf( "%d", &n );
    max_edges = n * ( n – 1 ); /* Taking directed graph */
    for ( i = 1;i <= max_edges;i++ )
        {
            printf( "Enter edge %d( 0 0 ) to quit : ", i );
            scanf( "%d %d", &origin, &destin );
            if ( ( origin == 0 ) && ( destin == 0 ) )
                break;
            if ( origin > n || destin > n || origin <= 0 || destin <= 0 )
                {
                    printf( "Invalid edge!\n" );
                    i–;
                }
            else
                adj[ origin ][ destin ] = 1;
        } /*End of for*/
} /*End of create_graph()*/
display()
{
    int i, j;
    for ( i = 1;i <= n;i++ )
        {
            for ( j = 1;j <= n;j++ )
                printf( "%4d", adj[ i ][ j ] );
            printf( "\n" );
        }
} /*End of display()*/
insert_node()
{
    int i;
    n++; /*Increase number of nodes in the graph*/
    printf( "The inserted node is %d \n", n );
    for ( i = 1;i <= n;i++ )
        {
            adj[ i ][ n ] = 0;
            adj[ n ][ i ] = 0;
        }
} /*End of insert_node()*/
delete_node( char u )
{
    int i, j;
    if ( n == 0 )
        {
            printf( "Graph is empty\n" );
            return ;
        }
    if ( u > n )
        {
            printf( "This node is not present in the graph\n" );
            return ;
        }
    for ( i = u;i <= n – 1;i++ )
        for ( j = 1;j <= n;j++ )
            {
                adj[ j ][ i ] = adj[ j ][ i + 1 ]; /* Shift columns left */
                adj[ i ][ j ] = adj[ i + 1 ][ j ]; /* Shift rows up */
            }
    n–; /*Decrease the number of nodes in the graph */
} /*End of delete_node*/
insert_edge( char u, char v )
{
    if ( u > n )
        {
            printf( "Source node does not exist\n" );
            return ;
        }
    if ( v > n )
        {
            printf( "Destination node does not exist\n" );
            return ;
        }
    adj[ u ][ v ] = 1;
} /*End of insert_edge()*/
del_edge( char u, char v )
{
    if ( u > n || v > n || adj[ u ][ v ] == 0 )
        {
            printf( "This edge does not exist\n" );
            return ;
        }
    adj[ u ][ v ] = 0;
} /*End of del_edge()*/

Source: www.codeproject.com

Add Comment

0

All those coders who are working on the Javascript based application and are stuck on delete node in graph in c can get a collection of related answers to their query. Programmers need to enter their query on delete node in graph in c related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about delete node in graph in c for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of delete node in graph in c while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "delete node in graph in c". Visit this developer's friendly online web community, CodeProZone, and get your queries like delete node in graph in c resolved professionally and stay updated to the latest Javascript updates. 

Javascript answers related to "delete node in graph in c"

View All Javascript queries

Javascript queries related to "delete node in graph in c"

delete node in graph in c reflection of an graph javascript JSDOM - getting source location of a node with `nodeLocation(node)` // `parse5` lib helps to serialize and/or parse refresh after delete in node node js send javascript node js sendgrid node js serve pdf file node js server node js sleep between axios node js split node js sqlite3 node js stop node js store add values in file node js store values in file node js sublime text Node Js templates node js throw error node js to check 32 bit node js try catch node js type error node js TypeError [ERR_INVALID_ARG_TYPE]: The argument must be of type string. Received undefined node js unix timestamp node js utf8 encode node js util promisify node js variable inside string node js version node js write file node js write read string to file node json stringify node list files in directory node load file node load string from file Node Locking node lodash documentation node log centered node log docker node mailer office 365 node main node map has value node minimal db example node module export multiple functions node mongoose save document node node_modules/protractor/bin/webdriver-manager update node open file node package.json type module node parameter add memory node path resolve node pg array in node print stdin node promisify without err node random string node read file node read file line node read file stream node read file sync node readFileSync json node red admin password setting node red debug to console node red flow.set objectid is not defined node js mongodb onclick node js open folder node js orm for postgres node js print in node js process.argv[2] node js promp node js random string generator node js Razorpay generate Signature in the node js read data from url node js read directory in node js read html file node js read txt file in node js receiving big response node js redis set expire time node js referenceerror document is not defined node js ReferenceError: fs is not defined node js render html in node js request.end request.write node js rest api node js with mysql update node version debian upgrade node version Node Sass version 5.0.0 is incompatible with ^4.0.0. js make node with string export command for node in heroku npm rebuild node-sass node.js 8 has been deprecated. firebase functions jest debugger node search string in file node grpc node node.js Error: Node Sass version 5.0.0 is incompatible with ^4.0.0 node-schedule npm import syntax node node-lambda run error fs-extra\lib\mkdirs\make-dir.js } catch { Unexpected token facebook integration in node.js how to run multple port node how to install reveal.js from node node-pg interval node js docker compose node input node js creating server node js serve pdf file node js sleep The engine "node" is incompatible with this module. Expected version "^14". Got "15.4.0" How to uninstall npm modules in node js? Node js fetch String interpolation node js mongoose find by and delete delete element from list javascript mongodb delete duplicate documents delete value from json array with index delete class through the dom how to delete an item on click in js mongoose delete object from array how to delete firebase collection typescript delete value from map

Browse Other Code Languages

CodeProZone