osm data to a graph data structure


I’m new to OSM and I would like to use it to test some idea on public transport itinerary optimisation. So I need to create a weighted graph where nodes are locations and edges road between them.

I have downloaded a osm.pbf file of a city and I have a go to read this file and get the nodes / way / relation out of it.

But now I’m a bit lost at where to start. How can I extract road from all those data ?
From the docs about OSM data structure (https://wiki.openstreetmap.org/wiki/Elements), I understand the I should look at Ways, but even so, ways are not only road. How can I know if a way is a road or something else ?

I don’t need a detailed solution on how to do that, just some hints / link / documentations / etc. to help me get started would be much appreciated :slight_smile:

There are a number of tools that can generate a nodes and edges graph for routing from OSM data. I am using osm2pgrouting for one of my side projects. Project page for that is at https://pgrouting.org/docs/tools/osm2pgrouting.html

Relevant tag:

Tools I’ve used for manipulating data: