View the step-by-step solution to:

Real world PR x How do Course Hero View Homewe A Assignment 7 Assignment & x Google Trans Adjacenty Lis Not secure / staffwww . full call .

http://staffwww.fullcoll.edu/aclifton/cs133/assignment7.html

http://staffwww.fullcoll.edu/aclifton/cs133/files/assign7_test.cpp




my graph.hpp look like this

2018-12-01 (1).png2018-12-01.png

2018-11-30.png2018-11-30 (1).png

2018-11-30 (1).png

Real world PR x
How do Course Hero
View Homewe
A Assignment 7
Assignment & x
Google Trans
Adjacenty Lis
Not secure / staffwww . full call . edu / aclifton / est 30 / assignment / html
count nodes ( )
Returns the number of nodes in this graph
Should run in of1 ) time
int count nodes ( )
count edges ( )
Returns the total number of edges in this graph
should run in GIE ) time
int count edges ( )
count edges ( n )
Returns the number of outbound edges from node
Should run in QE ) time
int count edges ( Int n )
* ofs ( n )
Perform a breadth-first search , starting at node in ,
returning a
Doctor that Blues
distance to every other node . ( If a node is
reachable from n , then set its distance to INT MAX . )
should run in OFF + N ) time
sted : :vectors ints bots ( int n )
is connected ( @ , b )
Returns true if a path exists from node a to b
Should run in o (E + N ) time
bool is connected ( int a , int b )
Add any private data / function members you need
1 Type here to search

2018-11-30.png

Real world PR x
How do Course Hero * View Homewor
A Assignment 7
Assignment 6 * Google Trans
Adjacenty Lis
Not secure / staffwww . full call . edu / aclifton / est 30 / assignment / html
Hipragna once
graph . hop
* Adjacenty - list graph implementation
include <clinics / For INT HAX , INT HIN
include <lists
Hinclude svector
class graphit
public
graph ( )
Construct a graph with a nodes and no edges , initially
graph ( int n )
add edge ( @ , b )
Add an edge from node a to node b . Note that self edges are not allowed
so attempting add edge ( a a ) should be ignored . Similarly , this is not
multigraph , so if an edge a - b already exists , a second one should
Ignored
in ONE ) time in the worst case
add edge ( int a , int b ) ;
has edge ( a , b )
Returns true if there is an edge from a to b . Should return false if
either a or b is out-of - range ( < & or > = count nodes ( ) )
Should run in O ( E ) time
bool has edge ( int a , int b )
count nodes ( )
1 Type here to search

2018-12-01 (1).png

[email protected]: ~/cs133/assign7
31
32
33
2 graph : :graph (int n) {
adj= new list [n] ;
34
35
void graph : : add_edge (int a, int b) {
36
node*
tmp;
tmp-
e=b ;
tmp->
->next=nullptr;
40
adj [a] . head->next=tmp
int graph : : count_nodes ( ) {
return n;
45
int graph : : count_edges ( ) {
int count=0;
for (int i=
t i=0;i<n;i++) {
node *
* a adj [il
1 . head ;
while (a->next ! =nullptr) {
count++;
a=a->next ;
return count ;
int graph : : count_edges (int n) {
int count=0;
node* a=adj [n] . head ;
while (a->next !=nullptr) {
count++;
a=a->next ;
return count ;
bool graph : :has edge (int a,
node * t
* tmp adj [a] . head;
int b) {
while (tmp->next ! =nullptr) {
if ( tmp->value==b)
return true
tmp=tmp->next ;
OUS WNFOO
return false;
vector<int> graph : :bfs (int n) {
graph . hpp + (31, 3)
c++ unix
Alt-g:
show bindings,
CtrlG:
open
help
O Type here to search
e 9 AM x
W
6 41)) . ENG
11:29 PM
12/1/2018

2018-12-01.png

[email protected]: ~/cs133/assign7
O
5 struct list{
node* head;
18
class graph
int n;
list*
* adj;
public:
graph (int n) ;
void add edge (int a, int b) ;
bool has edge (int a,
int b) ;
int count_nodes ( )
int count edges ( ) ;
int count edges (
s ( int n)
vector<int>
bfs (int n) ;
bool is c
int b) ;
33
graph : : graph (int n) {
adj= new list [n] ;
34
35
void graph : :add_edge (int a, int b) {
node *
tmp;
38
tmp->value=b;
tmp->next=nullptr ;
adj [a] . head->next=tmp
NE
int graph : : count_nodes ( ) {
return n;
14
45
int graph : : count_edges ( ) {
int count=0;
for (int i=0;i<n ;i++) {
node *
* a-adj [i] .r
) . head ;
while (a->next ! =nullptr) {
count++;
a=a->next ;
count;
int graph : : count_edges (int n) {
t=0 ;
node* a=adj [n] . head;
while (a->next ! =nullptr) {
$2
count++;
a=a->next ;
graph . hpp
31, 3)
c++ unix
Alt-g:
show bindings,
CtrlG:
open
help
O Type here to search
e 9 AM x
W
6 41)) . ENG
11:29 PM
12/1/2018

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question