BookmarkSubscribeRSS Feed
JacobSimonsen
Barite | Level 11

Hello everyone,

I try implement a graph theoretical algorithm in a DS2 datastep. I have problem with finding an elegant way to represent a graph. It should be such that I can find a vertice directly without going sequentilly throug all vertices, and same with edges.

I have tried doing this with three hash-objects: one that are indexed by the vertice from which arrows goes from, one indexed by vertices that arrows goes to, and one with both. This is clumpsy I think, since same information is saved several time. But neccessary since I need indexes on all three (vertices with arrows from, vertices with arrow to and the arrows indexed by both from- and end vertice).  Has anyone a better suggestion for representing a graph?

declare package hash edges([from_ to_],[from_ to_ capacity used],8,'','no','','','no')

                         tos([to_],[from_ to_ capacity used],8,'','no','','','multidata')

                         froms([from_],[from_ to_ capacity used],8,'','no','','','multidata')

graph.gif

   

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 0 replies
  • 611 views
  • 0 likes
  • 1 in conversation