473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

I Need help converting this to python i hope someone will help me :(

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. /*ADJACENCY MATRIX*/
  4. int source,X,Y,time,visited[20],Z[20][20];
  5. void DFS(int p)
  6. {
  7. int q;
  8. visited[p]=1;
  9. printf(" %d->",p+1);
  10. for(q=0;q<X;q++)
  11. {
  12. if(Z[p][q]==1&&visited[q]==0)
  13. DFS(q);
  14. }
  15. }
  16. int main()
  17. {
  18. int p,q,x1,x2;
  19. printf("\t\t\tGraphs\n");
  20. printf("Enter the required number of edges:");
  21. scanf("%d",&Y);
  22. printf("Enter the required number of vertices:");
  23. scanf("%d",&X);
  24. for(p=0;p<X;p++)
  25. {
  26. for(q=0;q<X;q++)
  27. Z[p][q]=0;
  28. }
  29. /*creating edges : */
  30. for(p=0;p<Y;p++)
  31. {
  32. printf("Enter the format of the edges (format: x1 x2) : ");
  33. scanf("%d%d",&x1,&x2);
  34. Z[x1-1][x2-1]=1;
  35. }
  36. for(p=0;p<X;p++)
  37. {
  38. for(q=0;q<X;q++)
  39. printf(" %d ",Z[p][q]);
  40. printf("\n");
  41. }
  42. printf("Enter the source of the DFS: ");
  43. scanf("%d",&source);
  44. DFS(source-1);
  45. return 0;
  46. }
Mar 30 '22 #1
1 9812
dev7060
636 Expert 512MB
I Need help converting this to python i hope someone will help me :(
What have you done so far?
Apr 9 '22 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: chuck amadi | last post by:
any python script which will parse an email messages into a file to poplulate a database. Im trying with UnixMailbox but I cant figure out howto abstract the all email data messages to a file . ...
3
by: Caleb Hattingh | last post by:
Hi all I saw it on a webpage a few days ago, can't seem to find it again. Tried a google search for "pypy needed translate C modules" but that didn't turn up what I was looking for. ...
6
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text...
1
by: sparks | last post by:
I have done a LOT of databases in access 97 but I am new to access 2000. We are S L O W L Y converting over. Yesterday I had a 97 database that I had to run the converter to 2000 and everything...
3
by: sparks | last post by:
I have 2 fields that I have to make sure don't get screwed up. (could be one it doesn't matter) but what they want is no duplicates, warn the user changing existing numbers is a no no. (of course...
14
by: mistral | last post by:
Need compile python code, source is in html and starts with parameters: #!/bin/sh - "exec" "python" "-O" "$0" "$@" I have installed ActivePython for windows.
4
by: charonzen | last post by:
I have a list of strings. These strings are previously selected bigrams with underscores between them ('and_the', 'nothing_given', and so on). I need to write a regex that will read another text...
3
by: Abrahamay | last post by:
I need a good program that will copy my DVD video to my computer and convert it to WMV or AVI in high quality, with no distortion to the sound or video. No trials, i already have several. I want...
2
by: Ken Jones | last post by:
Table URL_3 consist of the following 2 columns of information being Record No and URL No URL 1 http:/publishing/45/100006_f.SAL_Local.html 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.