Yes, it is illegal. There are generally two places that bikes are allowed to ride on the road with vehicles. The first are bike lanes. The purpose of the bike lanes are to keep the bicyclists and the drivers separated from each other which reduces the likelihood of an accident. The second place a bicyclist can ride is on the shoulder of a road. The whole point of is to make sure that bicyclists are isolated to a particular area so they do not cause an accident. If a bicyclist weaves in and out of traffic, and a police officer spots this, then the cyclist can be charged with reckless driving. The cyclist must stay in his/her lane, and not stop traffic from regularly flowing.