Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8491711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:30:36+00:00 2026-06-10T22:30:36+00:00

I have a question on one of the previous Stack Overflow post @ Knight's

  • 0

I have a question on one of the previous Stack Overflow post @ Knight's Shortest Path on Chessboard

I understand the reply on ‘ok, it’s a graph question, and its sparse matrix is like’:

(a1,b3)=1,
(a1,c2)=1,
  .....

which describe existing edges. However i still don’t know what Data Structure of this Graph should looks like (is it an adjacency matrix? stated as ‘sparse matrix’ above, or something else?), so that it can be readily used by Dijkstra’s algorithm.

http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm.

From the algorithm description, it looks convenient if the graph data structure is a set of vertex, with neighbor vertex information available. But how do we achieve this?

How can I write out a sample data structure for this graph? I am seeking an understanding of how it can be linked conveniently to Dijkstra’s algorithm.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:30:38+00:00Added an answer on June 10, 2026 at 10:30 pm

    The graph is very sparse (64 vertices, each vertex has at most 8 edges) thus an adjacency matrix is a waste IMO.

    A better structure for this will be adjacency list:

    v1->v2,v3,v4,v5
    v2->v1,...
    ...
    

    The idea is indeed to hold a Set<Vertex>, and for the Vertex type to have a field: List<Vertex> neighbors, which will contain all the vertex’s neighboring vertices.

    There is no need in this case for some additional weight information – since the graph is unweighted.

    Also – Dijkstra’s algorithm is redundant in here. Again, the graph is unweighted – so a simpler (to program and understand) and faster (run time) algorithm to find the shortest path is a BFS for unweighted graphs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to my previous question , but a different one. I have
Previous question here: stack overflow with Google maps API (IE7 IE8) I found the
i have one question about jquery ajax().. I created a table grid and there
I have one question; In my ASP.NET MVC web application have to do certain
I have one question about searching and counting files in directories and subdirectories. I
I have one question about Yii framework, and I need your help. Basicly, I
I have one question, I was trying to find more information on the internet
I have one question, in my company we are using Toxicity report to measure
I have one question. I am using Apache CXF framework to generate model classes
I am learning JPA and have one question: In which situations we need more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.