Convert osm to weighted precise graph

We have to form a weighted precise graph representation of the road structure of small towns in US. We got the raw map data in xml format from OSM, and tried to convert it to a graph (using networkx), but are lost somehow. We want each crossroad to form a node and the weights should be the distance between the two points on the map.

Is there any application which can convert the map data to the weighted graph? If not, please suggest some way to proceed.

Eventually we want to form graphs of a few such towns and try to find similarity in their road structure by finding similar subgraphs .

Maybe some hints are in the OSM wiki?

Have a look at the wiki pages called Frameworks, Routing, Develop … at