• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Nicholas Kong

Finding a path of length n in a graph

14 posts in this topic

[url=http://s33.photobucket.com/user/warnexus/media/path_zpsb4b2abdd.png.html]path_zpsb4b2abdd.png[/URL]

 

[url=http://s33.photobucket.com/user/warnexus/media/K4_zpse47064df.png.html]K4_zpse47064df.png[/URL]

 

I am doing part a of Ex 19. The answer has 2 but I can list at least 11 paths.

 

Here are the paths:

1) {a,b,d}

2) {a,d,c}

3) {a,c,d}

4) {b,a,c}

5) {b,d,c}

6) {b,c,d}

7) {c,a,b}

8) {c,d,b}

9) {d,b,a}

10) {d,c,a}

11) {d,b,c}

 

The complete graph k4 graph does not have labeled vertices a,b,c,d.

So I am not sure if I can label a,b,c,d anywhere I want.

Edited by warnexus
0

Share this post


Link to post
Share on other sites

Assuming the diagonals count as 1, if you pick any 2 vertices, there will be only 2 paths of length 2 between them. This is what i assume you were supposed to do.

1

Share this post


Link to post
Share on other sites

Sure you can label them as you want.

 

I think you are misunderstanding the problem, though. I would interpret it as, “Pick two fixed vertices. Tell me how many paths of length 2 there are between them.” The beauty here is that you should get the same answer no matter which two vertices you pick – this is thanks to your graph being a complete one; the question would be ill-formed if it were for a different kind of graph.

0

Share this post


Link to post
Share on other sites

Assuming the diagonals count as 1, if you pick any 2 vertices, there will be only 2 paths of length 2 between them. This is what i assume you were supposed to do.

I think I get what you saying. So the 11 paths I listed are not correct.

0

Share this post


Link to post
Share on other sites

Sure you can label them as you want.

 

I think you are misunderstanding the problem, though. I would interpret it as, “Pick two fixed vertices. Tell me how many paths of length 2 there are between them.” The beauty here is that you should get the same answer no matter which two vertices you pick – this is thanks to your graph being a complete one; the question would be ill-formed if it were for a different kind of graph.

Well there are 2 edges between any two vertices you pick so 2 paths of length. Now that I am doing part b. I do not get the same answer as the textbook so I think I am struggling with what the question is actually saying

0

Share this post


Link to post
Share on other sites

I count

a) 2

b) 7

c) 20

d) 61

 

That's assuming that it's OK to repeat nodes and edges in the paths: I am not sure what precise definition you are using.

 

If you want more terms,

 

A(0) = 0, A(1) = 1, A(n) = 3*A(n-2) + 2*A(n-1) if n>1

Edited by Álvaro
0

Share this post


Link to post
Share on other sites

I count

a) 2

b) 7

c) 20

d) 61

 

That's assuming that it's OK to repeat nodes and edges in the paths: I am not sure what precise definition you are using.

 

If you want more terms,

 

A(0) = 0, A(1) = 1, A(n) = 3*A(n-2) + 2*A(n-1) if n>1

You did get them all correct. You mention you counting the edges, so you do not need to write them down on a piece of paper?

 

Can you explain how you get 7 for part b?

 

I think if I understand how 7 was acheived I should be able to get part c and d intuitively. part a seems to do a poor job of figuring out how the thought process should be approached.

Edited by warnexus
0

Share this post


Link to post
Share on other sites

A(0) = 0, A(1) = 1, A(n) = 3*A(n-2) + 2*A(n-1) if n>1

To find a path with length n you need to find a path with length n-1 to any of the other nodes. You have 2 options:
1. Find a path to a node other than the start node. So 2 possible nodes, and you need a path of length n-1 to get to them. This is the 2*A(n-1) term.

2. Find a n-1 path to the start node. To do that, you need a n-2 path to any of the other 3 nodes. That's the 3*A(n-2) term.
1

Share this post


Link to post
Share on other sites

 

A(0) = 0, A(1) = 1, A(n) = 3*A(n-2) + 2*A(n-1) if n>1

To find a path with length n you need to find a path with length n-1 to any of the other nodes. You have 2 options:
1. Find a path to a node other than the start node. So 2 possible nodes, and you need a path of length n-1 to get to them. This is the 2*A(n-1) term.

2. Find a n-1 path to the start node. To do that, you need a n-2 path to any of the other 3 nodes. That's the 3*A(n-2) term.

 

Oh I get it now. I was doing it wrong the whole time. Thanks for the explaination.

0

Share this post


Link to post
Share on other sites

Oh, also

 

A(n) = (pow(3,n)-pow(-1,n))/4

 

Magic! smile.png

I was just driving my car and thinking about the non-recursive solution...

0

Share this post


Link to post
Share on other sites

Oh, also

 

A(n) = (pow(3,n)-pow(-1,n))/4

 

Magic! smile.png

Wow! Holy cow! That is awesome! Strange how my textbook does not have that formula! How did you come up with that formula? That's ingenious.

0

Share this post


Link to post
Share on other sites

You start at `a' and then you have three choices at each step. Of the possible paths, only 1/4 of them will end at the right spot, so the formula is pow(3,n)/4. Well, powers of 3 are not usually divisible by 4, so you need to do some rounding. </mostly kidding>

Once you have the recursive formula, you can find the explicit formula by trying to find the numbers x such that pow(x,n) satisfies the recursive formula.

pow(x,n) = 3*pow(x,n-2) + 2*pow(x,n-1)

Dividing by pow(x,n-2), you get

x^2 = 3 + 2*x => x^2 - 2*x - 3 = 0

Solving the quadratic equation, you find out that 3 and -1 are the roots. Now all the sequences that satisfy the recursive formula form a vector space of dimension 2 (because the one that starts (1,0,...) and the one that starts (0,1,...) are a basis), and you just found two independent vectors. If you don't know what on Earth I am talking about, don't worry. It means that any sequence that satisfies the recursive formula can be expressed as a*pow(3,n) + b*pow(-1,n), for appropriate values of a and b. Since we know A(0)=0 and A(1)=1,

a*pow(3,0) + b*pow(-1,0) = 0 => a + b = 0
a*pow(3,1) + b*pow(-1,1) = 1 => 3*a - b = 1

Solving that system of linear equations, you get a=1/4, b=-1/4, and that gives us the explicit formula.

This may look like magic if you haven't seen it before, but it's just a procedure you learn.

Edited by Álvaro
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0