trixs Posted July 26, 2006 Share Posted July 26, 2006 (edited) Hello Everyone! What I am trying to do is a little difficult to explain however, I am trying anyway!! I simply need ideas how you would code the following. I really dont need the exact code, as I am fairly good, just simply ideas. How I should go about it simply confuses me The Discription Part! Yay! Below is an example of a rather large CSV file I have. In fact it is around 13000 rows long. Each column is labled either fromSolarSystemID or toSolarSystemID. This file simply list each solarsystem and what other solarsytems it can connect to. For instance solarsystem 30000001 can goto systems 30000003, 30000005, 30000007 and 30003491. Each of these other solarsystems all have systems they can connect to aswell. If you look at FromSolarSytemID 30000003 you will see it can connect four systems in total. I hope this explains how this file works. Now you wonder, what ishe trying to do?! Lets say I am in system 30000001 and want to arrive in system 30000084. I want to know what is the shortest route(the number to pass through) and which systems they are. The human eye can pick this example out easy. We would start in 30000001 then go to 30000003 and finally 30000084. Does anyone have any ideas? I am at a loss with this one. Rolled around all night thinking about it before I posted. Thanks! fromSolarSystemID toSolarSystemID 30000001 30000003 30000001 30000005 30000001 30000007 30000001 30003491 30000002 30000005 30000002 30002973 30000003 30000001 30000003 30000007 30000003 30000052 30000003 30000084 30000004 30000005 30000004 30002509 30000005 30000001 30000005 30000002 30000005 30000004 30000005 30000032 30000006 30000008 30000006 30000023 30000007 30000001 30000007 30000003 30000007 30000008 30000008 30000006 30000008 30000007 30000008 30000057 30000008 30000076 30000009 30000010 30000010 30000009 30000010 30000011 30000010 30000013 30000011 30000010 30000011 30000038 30000012 30000013 30000012 30000073 30000013 30000010 30000013 30000012 30000013 30000014 30000013 30000015 30000013 30000016 30000014 30000013 Edited July 26, 2006 by trixs Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 26, 2006 Moderators Share Posted July 26, 2006 (edited) If I'm understanding you correctly, then it sounds like you just need a 2 dimensional array, then poll through them. [0] will be the from [1] will be the to I've pasted what you had in a text file and did this to see if it would work, then you can poll however you need to get the correct answers I guess:$GetArray = _Create2Dim(@DesktopDir & '\Solar.txt') If IsArray($GetArray) Then For $i = 1 To UBound($GetArray, 1) - 1 MsgBox(64, 'Info', 'fromSolarSystemID = ' & $GetArray[$i][0] & _ @CR & 'toSolarSystemID = ' & $GetArray[$i][1]) Next EndIf Func _Create2Dim($hFile) Local $hFRead = FileRead($hFile) Local $aSplit = StringSplit($hFRead, @LF) Local $aAdd, $aAdd2 For $iCount = 1 To $aSplit[0] - 1 $aSplit2 = StringSplit($aSplit[$iCount], Chr(32)) If $aSplit2[0] > 1 Then $aAdd &= $aSplit2[1] & Chr(01) $aAdd2 &= $aSplit2[2] & Chr(01) EndIf Next $aAdd = StringSplit(StringTrimRight($aAdd, 1), Chr(01)) $aAdd2 = StringSplit(StringTrimRight($aAdd2, 1), Chr(01)) Local $aReturn2Dim[$aAdd[0]][2] For $iCount = 1 To $aAdd[0] - 1 $aReturn2Dim[$iCount][0] = $aAdd[$iCount] $aReturn2Dim[$iCount][1] = $aAdd2[$iCount] Next Return $aReturn2Dim EndFuncRun this with the _Create2Dim() UDF above. Edited July 26, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
trixs Posted July 26, 2006 Author Share Posted July 26, 2006 Smoke, Thanks for the reply. Unfortunatly this problem is much more complex than simply finding whichever is located next to it. I probably didnt explain it verywell. Guess Ill think of a better way while I am at work Bye Link to comment Share on other sites More sharing options...
trixs Posted July 26, 2006 Author Share Posted July 26, 2006 Ok, After further research what I need is a Dijkstra's algorithm lol.. Hmm Going to be fun! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now